From b7d920149c010a704e83bfe1e713e4d08b488fcf Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Thu, 11 Jan 2018 09:59:42 +0700 Subject: [PATCH] Use uglifyjs-webpack-plugin v1 (#3618) --- .../config/webpack.config.prod.js | 42 +++++++++++-------- packages/react-scripts/package.json | 1 + 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 3b2a2068db2..e1d4bc14a28 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -12,6 +12,7 @@ const autoprefixer = require('autoprefixer'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ManifestPlugin = require('webpack-manifest-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); @@ -290,24 +291,31 @@ 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({ + uglifyOptions: { + 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, + }, }, + // Use multi-process parallel running to improve the build speed + // Default number of concurrent runs: os.cpus().length - 1 + parallel: true, + // Enable file caching + cache: true, sourceMap: shouldUseSourceMap, }), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f6bff1deaa6..33bff06c87c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,6 +53,7 @@ "react-dev-utils": "^4.2.1", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", + "uglifyjs-webpack-plugin": "1.1.4", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4",