forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-themes.js
44 lines (41 loc) · 1.35 KB
/
generate-themes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const config = require('../src/config.json');
const path = require('path');
const fs = require('fs-extra');
let sassFileStr = ``;
let tasks = [];
config.nav.map((item) => {
item.packages.forEach((element) => {
let folderName = element.name.toLowerCase();
tasks.push(
fs
.copy(
path.resolve(__dirname, `../src/packages/__VUE/${folderName}/index.scss`),
path.resolve(__dirname, `../dist/packages/${folderName}/index.scss`)
)
.then((success) => {
sassFileStr += `@import '../../packages/${folderName}/index.scss';\n`;
})
.catch((error) => {})
);
});
});
tasks.push(fs.copy(path.resolve(__dirname, '../src/packages/styles'), path.resolve(__dirname, '../dist/styles')));
Promise.all(tasks).then((res) => {
let themes = [
{ file: 'default.scss', sourcePath: `@import '../variables.scss';` },
{ file: 'jdt.scss', sourcePath: `@import '../variables-jdt.scss';` },
{ file: 'jdb.scss', sourcePath: `@import '../variables-jdb.scss';` },
{ file: 'jddkh.scss', sourcePath: `@import '../variables-jddkh.scss';` }
];
themes.forEach((item) => {
fs.outputFile(
path.resolve(__dirname, `../dist/styles/themes/${item.file}`),
`${item.sourcePath}
${sassFileStr}`,
'utf8',
(error) => {
// logger.success(`文件写入成功`);
}
);
});
});