@@ -41,6 +41,8 @@ const publicPath = paths.servedPath;
41
41
// Some apps do not use client-side routing with pushState.
42
42
// For these, "homepage" can be set to "." to enable relative asset paths.
43
43
const shouldUseRelativeAssetPaths = publicPath === './' ;
44
+ // Source maps are resource heavy and can cause out of memory issue for large source files.
45
+ const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false' ;
44
46
// `publicUrl` is just like `publicPath`, but we will provide it to our app
45
47
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
46
48
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
@@ -74,7 +76,7 @@ module.exports = {
74
76
bail : true ,
75
77
// We generate sourcemaps in production. This is slow but gives good results.
76
78
// You can exclude the *.map files from the build during deployment.
77
- devtool : 'source-map' ,
79
+ devtool : shouldUseSourceMap ? 'source-map' : false ,
78
80
// In production, we only want to load the polyfills and the app code.
79
81
entry : [ require . resolve ( './polyfills' ) , paths . appIndexJs ] ,
80
82
output : {
@@ -216,7 +218,7 @@ module.exports = {
216
218
options : {
217
219
importLoaders : 1 ,
218
220
minimize : true ,
219
- sourceMap : true ,
221
+ sourceMap : shouldUseSourceMap ,
220
222
} ,
221
223
} ,
222
224
{
@@ -307,7 +309,7 @@ module.exports = {
307
309
// https://github.com/facebookincubator/create-react-app/issues/2488
308
310
ascii_only : true ,
309
311
} ,
310
- sourceMap : true ,
312
+ sourceMap : shouldUseSourceMap ,
311
313
} ) ,
312
314
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
313
315
new ExtractTextPlugin ( {
0 commit comments