forked from jdf2e/nutui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-themes.js
49 lines (45 loc) · 1.29 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
45
46
47
48
49
const config = require('../src/config.json')
const path = require('path')
const fs = require('fs-extra')
const glob = require('glob')
let fileStr = `@import '../theme-default.scss';\n@import '../variables.scss';\n`
const projectID = process.env.VITE_APP_PROJECT_ID
if (projectID) {
fileStr = `@import '../theme-default.scss';\n@import '../variables-${projectID}.scss';\n`
}
let tasks = []
const componentsScss = glob.sync('./src/packages/**/*.scss', { dotRelative: true })
componentsScss.map((cs) => {
if (cs.indexOf('demo.scss') > -1) return
tasks.push(
fs
.copy(
path.resolve(__dirname, `.${cs}`),
path.resolve(__dirname, `../dist`, `${cs.replace('./src/', '')}`)
)
.catch((error) => { })
)
})
config.nav.map((item) => {
item.packages.forEach((element) => {
if (element.exclude) return
let folderName = element.name.toLowerCase()
fileStr += `@import '../../packages/${folderName}/${folderName}.scss';\n`
})
})
tasks.push(
fs.copy(
path.resolve(__dirname, '../src/styles'),
path.resolve(__dirname, '../dist/styles')
)
)
Promise.all(tasks).then((res) => {
fs.outputFile(
path.resolve(__dirname, '../dist/styles/themes/default.scss'),
fileStr,
'utf8',
(error) => {
// logger.success(`文件写入成功`);
}
)
})