Skip to content

Commit ff54494

Browse files
viankakrisnaTimer
authored andcommitted
Use uglifyjs-webpack-plugin v1 (facebook#3618)
1 parent d979964 commit ff54494

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

packages/react-scripts/config/webpack.config.prod.js

+25-17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const autoprefixer = require('autoprefixer');
1212
const path = require('path');
1313
const webpack = require('webpack');
1414
const HtmlWebpackPlugin = require('html-webpack-plugin');
15+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
1516
const ExtractTextPlugin = require('extract-text-webpack-plugin');
1617
const ManifestPlugin = require('webpack-manifest-plugin');
1718
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
@@ -290,24 +291,31 @@ module.exports = {
290291
// Otherwise React will be compiled in the very slow development mode.
291292
new webpack.DefinePlugin(env.stringified),
292293
// Minify the code.
293-
new webpack.optimize.UglifyJsPlugin({
294-
compress: {
295-
warnings: false,
296-
// Disabled because of an issue with Uglify breaking seemingly valid code:
297-
// https://github.com/facebookincubator/create-react-app/issues/2376
298-
// Pending further investigation:
299-
// https://github.com/mishoo/UglifyJS2/issues/2011
300-
comparisons: false,
301-
},
302-
mangle: {
303-
safari10: true,
304-
},
305-
output: {
306-
comments: false,
307-
// Turned on because emoji and regex is not minified properly using default
308-
// https://github.com/facebookincubator/create-react-app/issues/2488
309-
ascii_only: true,
294+
new UglifyJsPlugin({
295+
uglifyOptions: {
296+
compress: {
297+
warnings: false,
298+
// Disabled because of an issue with Uglify breaking seemingly valid code:
299+
// https://github.com/facebookincubator/create-react-app/issues/2376
300+
// Pending further investigation:
301+
// https://github.com/mishoo/UglifyJS2/issues/2011
302+
comparisons: false,
303+
},
304+
mangle: {
305+
safari10: true,
306+
},
307+
output: {
308+
comments: false,
309+
// Turned on because emoji and regex is not minified properly using default
310+
// https://github.com/facebookincubator/create-react-app/issues/2488
311+
ascii_only: true,
312+
},
310313
},
314+
// Use multi-process parallel running to improve the build speed
315+
// Default number of concurrent runs: os.cpus().length - 1
316+
parallel: true,
317+
// Enable file caching
318+
cache: true,
311319
sourceMap: shouldUseSourceMap,
312320
}),
313321
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.

packages/react-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"react-dev-utils": "^5.0.0",
5454
"style-loader": "0.19.0",
5555
"sw-precache-webpack-plugin": "0.11.4",
56+
"uglifyjs-webpack-plugin": "1.1.4",
5657
"url-loader": "0.6.2",
5758
"webpack": "3.8.1",
5859
"webpack-dev-server": "2.9.4",

0 commit comments

Comments
 (0)