generate-themes.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/packages/${folderName}/index.scss`)
  14. )
  15. .then((success) => {
  16. fileStr += `@import '../../packages/${folderName}/index.scss';\n`;
  17. })
  18. .catch((error) => {})
  19. );
  20. });
  21. });
  22. tasks.push(fs.copy(path.resolve(__dirname, '../src/packages/styles'), path.resolve(__dirname, '../dist/styles')));
  23. Promise.all(tasks).then((res) => {
  24. fs.outputFile(path.resolve(__dirname, '../dist/styles/themes/default.scss'), fileStr, 'utf8', (error) => {
  25. // logger.success(`文件写入成功`);
  26. });
  27. fs.outputFile(
  28. path.resolve(__dirname, '../dist/styles/themes/jdd.scss'),
  29. `$primary-color: #2c68ff;
  30. $primary-color-end: #2c68ff;`,
  31. 'utf8',
  32. (error) => {
  33. // logger.success(`文件写入成功`);
  34. }
  35. );
  36. });