-
Notifications
You must be signed in to change notification settings - Fork 18
/
config-overrides.js
67 lines (62 loc) · 1.74 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
61
62
63
64
65
66
67
const path = require('path');
const lessVariables = require('./config.themeVariable');
const {
override,
setWebpackOptimizationSplitChunks,
fixBabelImports,
addLessLoader,
setWebpackPublicPath,
addWebpackAlias,
} = require('customize-cra');
const multipleEntry = require('react-app-rewire-multiple-entry')([
{
entry: 'src/dashboard/index.tsx',
template: 'public/yugong.html',
outPath: '/dashboard/index.html',
},
{
entry: 'src/index.tsx',
outPath: '/index.html',
},
]);
const config = override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true, // change importing css to less
}),
addLessLoader({
lessOptions: {
javascriptEnabled: true,
modifyVars: lessVariables,
},
additionalData:
"@import 'node_modules/antd/lib/style/themes/default.less';",
}),
setWebpackPublicPath(process.env.REACT_APP_PUBLIC_PATH),
addWebpackAlias({
'~': path.resolve(__dirname, './src'),
}),
setWebpackOptimizationSplitChunks({
minSize: 30,
name: false,
cacheGroups: {
default: {
name: 'common',
chunks: 'initial',
minChunks: 2, //模块被引用2次以上的才抽离
priority: -20,
},
vendors: {
//拆分第三方库(通过npm|yarn安装的库)
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'initial',
maxSize: 300000,
priority: -10,
}
},
}),
multipleEntry.addMultiEntry
);
module.exports = config;