generate-themes-dev.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const config = require('../src/config.json');
  2. const path = require('path');
  3. const fs = require('fs-extra');
  4. let fileStr = `@import '../variables.scss';\n`;
  5. let tasks = [];
  6. config.nav.map((item) => {
  7. item.packages.forEach((element) => {
  8. let folderName = element.name.toLowerCase();
  9. tasks.push(
  10. fs
  11. .copy(
  12. path.resolve(__dirname, `../src/packages/__VUE/${folderName}/index.scss`),
  13. path.resolve(__dirname, `../dist/theme/source/packages/${folderName}/index.scss_source`)
  14. )
  15. .then((success) => {
  16. fileStr += `@import '../../packages/${folderName}/index.scss';\n`;
  17. })
  18. .catch((error) => {})
  19. );
  20. });
  21. });
  22. tasks.push(
  23. fs.copy(path.resolve(__dirname, '../src/packages/styles'), path.resolve(__dirname, '../dist/theme/source/styles'))
  24. );
  25. tasks.push(
  26. fs.copy(
  27. path.resolve(__dirname, '../src/packages/styles/variables.scss'),
  28. path.resolve(__dirname, '../dist/theme/source/styles/variables.scss_source')
  29. )
  30. );
  31. Promise.all(tasks).then((res) => {
  32. fs.outputFile(
  33. path.resolve(__dirname, '../dist/theme/source/styles/themes/default.scss'),
  34. fileStr,
  35. 'utf8',
  36. (error) => {
  37. // logger.success(`文件写入成功`);
  38. }
  39. );
  40. });