-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig-overrides.js
45 lines (40 loc) · 1.18 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
const path = require('path');
const {override, addWebpackAlias, addDecoratorsLegacy, fixBabelImports, addLessLoader} = require('customize-cra');
const WebpackBar = require('webpackbar');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
const addCustomize = () => (config) => {
if (process.env.ANALYZE) {
if (config.plugins) {
config.plugins.push(
new BundleAnalyzerPlugin()
);
}
}
if (config.plugins) {
config.plugins.push(
new WebpackBar({
color: 'purple',
name: 'ssr'
}),
new AntdDayjsWebpackPlugin()
);
}
const loaders = config.module.rules.find(rule => Array.isArray(rule.oneOf)).oneOf;
// 开启cssmodules
loaders[3].use[1].options.modules = true;
return config;
};
module.exports = override(
addCustomize(),
addWebpackAlias({
'@': path.resolve(__dirname, 'src'),
'src': path.resolve(__dirname, 'src')
}),
addDecoratorsLegacy(["@babel/plugin-proposal-decorators", {"legacy": true}]),
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: 'css'
})
);