|
@@ -1,3 +1,4 @@
|
|
|
|
+/* eslint-disable camelcase */
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
|
|
|
|
@@ -7,14 +8,41 @@ const optimization = {
|
|
minimize: isProduction,
|
|
minimize: isProduction,
|
|
minimizer: [
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
new TerserPlugin({
|
|
- minify: TerserPlugin.swcMinify,
|
|
|
|
terserOptions: {
|
|
terserOptions: {
|
|
|
|
+ parse: {
|
|
|
|
+ // We want terser to parse ecma 8 code. However, we don't want it
|
|
|
|
+ // to apply any minification steps that turns valid ecma 5 code
|
|
|
|
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
|
|
+ // sections only apply transformations that are ecma 5 safe
|
|
|
|
+ // https://github.com/facebook/create-react-app/pull/4234
|
|
|
|
+ ecma: 8,
|
|
|
|
+ },
|
|
compress: {
|
|
compress: {
|
|
- unused: true,
|
|
|
|
|
|
+ ecma: 5,
|
|
|
|
+ warnings: false,
|
|
|
|
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
|
|
+ // https://github.com/facebook/create-react-app/issues/2376
|
|
|
|
+ // Pending further investigation:
|
|
|
|
+ // https://github.com/mishoo/UglifyJS2/issues/2011
|
|
|
|
+ comparisons: false,
|
|
|
|
+ // Disabled because of an issue with Terser breaking valid code:
|
|
|
|
+ // https://github.com/facebook/create-react-app/issues/5250
|
|
|
|
+ // Pending further investigation:
|
|
|
|
+ // https://github.com/terser-js/terser/issues/120
|
|
|
|
+ inline: 2,
|
|
|
|
+ },
|
|
|
|
+ mangle: {
|
|
|
|
+ safari10: true,
|
|
},
|
|
},
|
|
- mangle: true,
|
|
|
|
- format: {
|
|
|
|
|
|
+ // Added for profiling in devtools
|
|
|
|
+ keep_classnames: isProduction,
|
|
|
|
+ keep_fnames: isProduction,
|
|
|
|
+ output: {
|
|
|
|
+ ecma: 5,
|
|
comments: false,
|
|
comments: false,
|
|
|
|
+ // Turned on because emoji and regex is not minified properly using default
|
|
|
|
+ // https://github.com/facebook/create-react-app/issues/2488
|
|
|
|
+ ascii_only: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
@@ -56,6 +84,27 @@ const optimization = {
|
|
priority: 10,
|
|
priority: 10,
|
|
reuseExistingChunk: true,
|
|
reuseExistingChunk: true,
|
|
},
|
|
},
|
|
|
|
+ antdVendors: {
|
|
|
|
+ name: 'antd',
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ test: /[\\/]node_modules[\\/](antd)/,
|
|
|
|
+ priority: 10,
|
|
|
|
+ reuseExistingChunk: true,
|
|
|
|
+ },
|
|
|
|
+ recharsVendors: {
|
|
|
|
+ name: 'rechars',
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ test: /[\\/]node_modules[\\/](recharts)/,
|
|
|
|
+ priority: 10,
|
|
|
|
+ reuseExistingChunk: true,
|
|
|
|
+ },
|
|
|
|
+ lodash: {
|
|
|
|
+ name: 'lodash',
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ test: /[\\/]node_modules[\\/](lodash)/,
|
|
|
|
+ priority: 10,
|
|
|
|
+ reuseExistingChunk: true,
|
|
|
|
+ },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|