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

Commit 244650d

Browse files
authored
Merge pull request #297 from meandmax/fix-uglify-config
fix(wepack.config.prod.js): set ecma option for compress and output to 5
2 parents a11f2f6 + c91a1a2 commit 244650d

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

+17-7
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,19 @@ module.exports = {
298298
new webpack.DefinePlugin(env.stringified),
299299
// Minify the code.
300300
new UglifyJsPlugin({
301-
parallel: true,
302-
cache: true,
303301
uglifyOptions: {
304-
ecma: 8,
302+
parse: {
303+
// we want uglify-js to parse ecma 8 code. However we want it to output
304+
// ecma 5 compliant code, to avoid issues with older browsers, this is
305+
// whey we put `ecma: 5` to the compress and output section
306+
// https://github.com/facebook/create-react-app/pull/4234
307+
ecma: 8,
308+
},
305309
compress: {
310+
ecma: 5,
306311
warnings: false,
307312
// Disabled because of an issue with Uglify breaking seemingly valid code:
308-
// https://github.com/facebookincubator/create-react-app/issues/2376
313+
// https://github.com/facebook/create-react-app/issues/2376
309314
// Pending further investigation:
310315
// https://github.com/mishoo/UglifyJS2/issues/2011
311316
comparisons: false,
@@ -314,15 +319,20 @@ module.exports = {
314319
safari10: true,
315320
},
316321
output: {
322+
ecma: 5,
317323
comments: false,
318324
// Turned on because emoji and regex is not minified properly using default
319-
// https://github.com/facebookincubator/create-react-app/issues/2488
325+
// https://github.com/facebook/create-react-app/issues/2488
320326
ascii_only: true,
321327
},
322328
},
329+
// Use multi-process parallel running to improve the build speed
330+
// Default number of concurrent runs: os.cpus().length - 1
331+
parallel: true,
332+
// Enable file caching
333+
cache: true,
323334
sourceMap: shouldUseSourceMap,
324-
}),
325-
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
335+
}), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
326336
new ExtractTextPlugin({
327337
filename: cssFilename,
328338
}),

0 commit comments

Comments
 (0)