-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.js
45 lines (42 loc) · 1.41 KB
/
color.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
const path = require('path');
const { generateTheme, getLessVars } = require('antd-theme-generator');
const fs = require("fs");
fs.mkdir('./public/static',function(err){
if(err){
console.log("主题目录创建失败",err)
}else{
console.log("主题目录创建成功");
fs.writeFile('./public/static/color.less',{},function(err){
if(err){
console.log("主题color.less文件写入失败",err)
}else{
console.log("主题color.less文件写入成功");
}
})
}
})
const options = {
stylesDir: path.join(__dirname, './src/styles'), //对应具体位置
antDir: path.join(__dirname, './node_modules/antd'), //对应具体位置
varFile: path.join(__dirname, './src/styles/vars.less'), //对应具体位置
mainLessFile: path.join(__dirname, './src/styles/main.less'), //对应具体位置
themeVariables: [
'@primary-color',
'@secondary-color',
'@text-color',
'@text-color-secondary',
'@heading-color',
'@layout-body-background',
'@btn-primary-bg',
'@layout-header-background'
],
indexFileName: 'index.html',
outputFilePath: path.join(__dirname, './public/static/color.less'),
}
generateTheme(options)
.then(less => {
console.log('Theme generated successfully');
})
.catch(error => {
console.log('Error', error);
});