-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig-overrides.js
57 lines (54 loc) · 1.51 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { override: configOverrides } = require('customize-cra');
const TerserPlugin = require('terser-webpack-plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const BrotliPlugin = require('brotli-webpack-plugin');
const isEnvProductionProfile =
process.env.NODE_ENV === 'production' && process.env.PROFILE === 'true';
module.exports = configOverrides((config, env) => {
if (env === 'production') {
config.optimization.minimizer = [
new TerserPlugin({
terserOptions: {
parse: {
ecma: 8,
},
compress: {
ecma: 5,
warnings: false,
comparisons: false,
inline: 2,
drop_console: true,
},
mangle: {
safari10: true,
},
keep_classnames: isEnvProductionProfile,
keep_fnames: isEnvProductionProfile,
output: {
ecma: 5,
comments: false,
ascii_only: true,
},
},
}),
];
config.plugins.push(
new CompressionWebpackPlugin({
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8,
}),
);
config.plugins.push(
new BrotliPlugin({
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8,
}),
);
config.devtool = isEnvProductionProfile ? 'source-map' : false;
}
return config;
});