-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
60 lines (57 loc) · 1.63 KB
/
config-overrides.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
50
51
52
53
54
55
56
57
58
59
60
const {
override,
addWebpackAlias,
adjustStyleLoaders,
addDecoratorsLegacy,
disableEsLint,
addWebpackPlugin,
} = require('customize-cra');
const chalk = require('chalk');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const path = require('path');
const addLessLoader = require('customize-cra-less-loader');
const exec = require('child_process').execSync;
process.env.REACT_APP_NAME = require('./package.json').name;
process.env.REACT_APP_VERSION = require('./package.json').version;
process.env.REACT_APP_BUILD_TIME = new Date().toLocaleString('zh-CN', {
hour12: false,
});
process.env.REACT_APP_GIT_COMMIT = exec('git rev-parse --short=8 HEAD')
.toString()
.trim();
module.exports = {
webpack: override(
// 配置alias
addWebpackAlias({
'@': path.resolve(__dirname, 'src'),
components: path.resolve(__dirname, 'src/components'),
mock: path.resolve(__dirname, 'src/mock'),
}),
// 添加less解析器
addLessLoader({
lessOptions: {
javascriptEnabled: true,
sourceMap: false,
// modifyVars: { '@primary-color': '#1DA57A' },
},
}),
adjustStyleLoaders((rule) => {
if (rule.test.toString().includes('less')) {
rule.use.push({
loader: 'style-resources-loader',
options: {
patterns: path.resolve(__dirname, 'src/styles/global.less'),
injector: 'append',
},
});
}
}),
addDecoratorsLegacy(),
disableEsLint(),
addWebpackPlugin(
new ProgressBarPlugin({
format: ` :msg [:bar] ${chalk.green.bold(':percent')} (:elapsed s)`,
}),
),
),
};