diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 65b50efa2..743c2e417 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -21,6 +21,7 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const paths = require('./paths'); const getClientEnvironment = require('./env'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); // Webpack uses `publicPath` to determine where the app is being served from. // It requires a trailing slash, or the file assets will get an incorrect path. @@ -296,23 +297,28 @@ module.exports = { // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), // Minify the code. - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false, - // Disabled because of an issue with Uglify breaking seemingly valid code: - // https://github.com/facebookincubator/create-react-app/issues/2376 - // Pending further investigation: - // https://github.com/mishoo/UglifyJS2/issues/2011 - comparisons: false, - }, - mangle: { - safari10: true, - }, - output: { - comments: false, - // Turned on because emoji and regex is not minified properly using default - // https://github.com/facebookincubator/create-react-app/issues/2488 - ascii_only: true, + new UglifyJsPlugin({ + parallel: true, + cache: true, + uglifyOptions: { + ecma: 8, + compress: { + warnings: false, + // Disabled because of an issue with Uglify breaking seemingly valid code: + // https://github.com/facebookincubator/create-react-app/issues/2376 + // Pending further investigation: + // https://github.com/mishoo/UglifyJS2/issues/2011 + comparisons: false, + }, + mangle: { + safari10: true, + }, + output: { + comments: false, + // Turned on because emoji and regex is not minified properly using default + // https://github.com/facebookincubator/create-react-app/issues/2488 + ascii_only: true, + }, }, sourceMap: shouldUseSourceMap, }), diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 1a89a04a2..58b6b550b 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -49,6 +49,7 @@ "tsconfig-paths-webpack-plugin": "^2.0.0", "tslint": "^5.7.0", "tslint-react": "^3.2.0", + "uglifyjs-webpack-plugin": "^1.1.8", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4",