Jelajahi Sumber

fix: plugin no animation.scss fallback

DaiQiangReal 3 tahun lalu
induk
melakukan
a6064489a6
1 mengubah file dengan 13 tambahan dan 3 penghapusan
  1. 13 3
      packages/semi-webpack/src/semi-theme-loader.ts

+ 13 - 3
packages/semi-webpack/src/semi-theme-loader.ts

@@ -8,7 +8,15 @@ export default function SemiThemeLoader(source: string) {
     const scssVarStr = `@import "~${theme}/scss/index.scss";\n`;
     // inject once
     const cssVarStr = `@import "~${theme}/scss/global.scss";\n`;
-    const animationStr = `@import "~${theme}/scss/animation.scss";\n`;
+    let animationStr = `@import "~${theme}/scss/animation.scss";\n`;
+
+    try {
+        require.resolve(`${theme}/scss/animation.scss`);
+    } catch (e) {
+        animationStr = ""; // fallback to empty string
+    }
+
+
     const shouldInject = source.includes('semi-base');
 
     let fileStr = source;
@@ -16,7 +24,8 @@ export default function SemiThemeLoader(source: string) {
     let componentVariables: string | boolean;
     try {
         componentVariables = resolve.sync(this.context, `${theme}/scss/local.scss`);
-    } catch (e) {}
+    } catch (e) {
+    }
 
     if (query.include || query.variables || componentVariables) {
         let localImport = '';
@@ -36,7 +45,8 @@ export default function SemiThemeLoader(source: string) {
                 fileSplit.splice(fileSplit.length - 1, 0, localImport);
                 fileStr = fileSplit.join('');
             }
-        } catch (error) {}
+        } catch (error) {
+        }
     }
 
     // inject prefix