Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit 39d6c62

Browse files
thetricDorianGrey
authored andcommitted
Uglifyjs update for es6 support (#249)
* feat(react-scripts/prod): use new uglifyJsPlugin for ES6 support this closes #21, #158, #248 * feat(react-scripts/prod): execute uglify plugin parallel + enable caching
1 parent ec0a39e commit 39d6c62

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

Diff for: packages/react-scripts/config/webpack.config.prod.js

+23-17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
2121
const paths = require('./paths');
2222
const getClientEnvironment = require('./env');
2323
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
24+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
2425

2526
// Webpack uses `publicPath` to determine where the app is being served from.
2627
// It requires a trailing slash, or the file assets will get an incorrect path.
@@ -296,23 +297,28 @@ module.exports = {
296297
// Otherwise React will be compiled in the very slow development mode.
297298
new webpack.DefinePlugin(env.stringified),
298299
// Minify the code.
299-
new webpack.optimize.UglifyJsPlugin({
300-
compress: {
301-
warnings: false,
302-
// Disabled because of an issue with Uglify breaking seemingly valid code:
303-
// https://github.com/facebookincubator/create-react-app/issues/2376
304-
// Pending further investigation:
305-
// https://github.com/mishoo/UglifyJS2/issues/2011
306-
comparisons: false,
307-
},
308-
mangle: {
309-
safari10: true,
310-
},
311-
output: {
312-
comments: false,
313-
// Turned on because emoji and regex is not minified properly using default
314-
// https://github.com/facebookincubator/create-react-app/issues/2488
315-
ascii_only: true,
300+
new UglifyJsPlugin({
301+
parallel: true,
302+
cache: true,
303+
uglifyOptions: {
304+
ecma: 8,
305+
compress: {
306+
warnings: false,
307+
// Disabled because of an issue with Uglify breaking seemingly valid code:
308+
// https://github.com/facebookincubator/create-react-app/issues/2376
309+
// Pending further investigation:
310+
// https://github.com/mishoo/UglifyJS2/issues/2011
311+
comparisons: false,
312+
},
313+
mangle: {
314+
safari10: true,
315+
},
316+
output: {
317+
comments: false,
318+
// Turned on because emoji and regex is not minified properly using default
319+
// https://github.com/facebookincubator/create-react-app/issues/2488
320+
ascii_only: true,
321+
},
316322
},
317323
sourceMap: shouldUseSourceMap,
318324
}),

Diff for: packages/react-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"tsconfig-paths-webpack-plugin": "^2.0.0",
5050
"tslint": "^5.7.0",
5151
"tslint-react": "^3.2.0",
52+
"uglifyjs-webpack-plugin": "^1.1.8",
5253
"url-loader": "0.6.2",
5354
"webpack": "3.8.1",
5455
"webpack-dev-server": "2.9.4",

0 commit comments

Comments
 (0)