forked from mzohaibqc/antd-live-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rescriptsrc.js
49 lines (44 loc) · 1.5 KB
/
.rescriptsrc.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 fs = require('fs');
const path = require('path');
const lessToJs = require('less-vars-to-js');
const AntDesignThemePlugin = require('antd-theme-webpack-plugin');
module.exports = [
['use-babel-config', '.babelrc'],
['use-eslint-config', '.eslintrc'],
config => {
const newConfig = config;
let rule = newConfig.module.rules.find(rule => rule.oneOf);
const paletteLess = fs.readFileSync('./src/styles/variables.less', 'utf8');
const variables = lessToJs(paletteLess);
const options = {
antDir: path.join(__dirname, './node_modules/antd'),
stylesDir: path.join(__dirname, './src/styles'),
varFile: path.join(__dirname, './src/styles/variables.less'),
mainLessFile: path.join(__dirname, './src/styles/index.less'),
themeVariables: Object.keys(variables), // ['@primary-color', '@secondry-color', '@text-color-secondary', '@text-color', '@processing-color', '@layout-header-background', '@heading-color', '@btn-primary-bg'],
indexFileName: 'index.html',
generateOnce: false
}
const themePlugin = new AntDesignThemePlugin(options);
rule.oneOf.unshift({
test: /\.less$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
modifyVars: variables
}
}
]
});
config.plugins.push(themePlugin);
return newConfig;
}
];