-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig-overrides.js
More file actions
110 lines (107 loc) · 2.85 KB
/
config-overrides.js
File metadata and controls
110 lines (107 loc) · 2.85 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* @Descripttion:
* @Author: tanwei
* @Date: 2020-08-08 14:28:50
* @LastEditors: tanwei
* @LastEditTime: 2021-01-29 10:06:15
* @FilePath: /open-platform/config-overrides.js
*/
const {
override,
addBabelPlugin,
addLessLoader,
// useEslintRc,
addDecoratorsLegacy,
addWebpackAlias,
addBabelPlugins,
addWebpackPlugin,
} = require('customize-cra');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const path = require("path");
const FileManagerPlugin = require('filemanager-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
// 是否是本地开发start启动的
const isBuild = process.env.NODE_ENV === 'production';
module.exports = override(
// useEslintRc(),
addBabelPlugin(
[
'import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
},
'ant',
],
[
'import',
{
libraryName: 'lodash',
libraryDirectory: '',
camel2DashComponentName: false,
},
'lo',
],
[
'import',
{
libraryName: 'ahooks',
libraryDirectory: '',
camel2DashComponentName: false,
},
],
),
...addBabelPlugins(
"@babel/plugin-proposal-do-expressions",
"@babel/plugin-proposal-function-bind",
"@babel/plugin-proposal-optional-chaining",
["@babel/plugin-syntax-dynamic-import"],
[
"@babel/plugin-proposal-pipeline-operator",
{
"proposal": "minimal"
}
],
),
addDecoratorsLegacy(),
addLessLoader({
lessOptions: {
javascriptEnabled: true,
modifyVars: {
// '@primary-color': '#1890ff',
},
}
}),
addWebpackAlias({
'@': path.resolve(__dirname, './src'),
}),
// addWebpackPlugin(new BundleAnalyzerPlugin())
addWebpackPlugin(
new FileManagerPlugin({
events: {
onEnd: {
delete: ['./build/build.zip'],
archive: [
{ source: './build', destination: './build/build.zip' },
],
},
}
}),
isBuild &&
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(js|css)$' //压缩 js 与 css
),
threshold: 102400,// 大约100kb处理 单位b
minRatio: 0.8
})
),
(config) => {
// 正式环境去掉打包生产map文件
if (isBuild) config.devtool = false;
return config;
}
);