UNPKG

1.29 kBJavaScriptView Raw
1module.exports = options => ({
2 uglifyOptions: {
3 // 强制使用 es5 压缩输出,避免 es6 优化导致兼容性问题
4 ecma: 5,
5 compress: {
6 collapse_vars: false, // 0.3kb
7 // Disabled because of an issue with Uglify breaking seemingly valid code:
8 // https://github.com/facebook/create-react-app/issues/2376
9 // Pending further investigation:
10 // https://github.com/mishoo/UglifyJS2/issues/2011
11 comparisons: false,
12 computed_props: false,
13 hoist_funs: false,
14 hoist_props: false,
15 inline: false,
16 loops: false,
17 negate_iife: false,
18 properties: false,
19 reduce_funcs: false,
20 reduce_vars: false,
21
22 // a few flags with noticable gains/speed ratio
23 // numbers based on out of the box vendor bundle
24 booleans: true, // 0.7kb
25 sequences: true, // 0.7kb
26
27 // required features to drop conditional branches
28 conditionals: true,
29 drop_console: options.console
30 },
31 mangle: {
32 safari10: true
33 },
34 output: {
35 // Turned on because emoji and regex is not minified properly using default
36 // https://github.com/facebook/create-react-app/issues/2488
37 ascii_only: true
38 }
39 },
40 sourceMap: options.sourceMap,
41 cache: true,
42 parallel: true
43})