Browse Source

fix: add style-deps of mjs

eiinu 3 years ago
parent
commit
df78a79233
1 changed files with 12 additions and 2 deletions
  1. 12 2
      jd/generate-style-deps.cjs

+ 12 - 2
jd/generate-style-deps.cjs

@@ -45,13 +45,23 @@ styleMap.forEach((value, key) => {
   deps = deps.filter((component) => {
     return component !== key;
   });
-  const output = `require('./index.scss');\n${deps
+  const outputJs = `require('./index.scss');\n${deps
     .map((component) => {
       return `require('../${component.toLowerCase()}/index.scss');\n`;
     })
     .join('')}`;
+  const outputMjs = `import './index.scss';\n${deps
+    .map((component) => {
+      return `import '../${component.toLowerCase()}/index.scss';\n`;
+    })
+    .join('')}`;
+  tasks.push(
+    fs.outputFile(path.resolve(__dirname, `../dist/packages/${name}/index.js`), outputJs, 'utf8', () => {
+      // console.log('')
+    })
+  );
   tasks.push(
-    fs.outputFile(path.resolve(__dirname, `../dist/packages/${name}/index.js`), output, 'utf8', () => {
+    fs.outputFile(path.resolve(__dirname, `../dist/packages/${name}/index.mjs`), outputMjs, 'utf8', () => {
       // console.log('')
     })
   );