@@ -28,6 +28,8 @@ const publicPath = paths.servedPath;
28
28
// Some apps do not use client-side routing with pushState.
29
29
// For these, "homepage" can be set to "." to enable relative asset paths.
30
30
const shouldUseRelativeAssetPaths = publicPath === './' ;
31
+ // Source maps are resource heavy and can cause out of memory issue for large source files.
32
+ const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false' ;
31
33
// `publicUrl` is just like `publicPath`, but we will provide it to our app
32
34
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
33
35
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
@@ -61,7 +63,7 @@ module.exports = {
61
63
bail : true ,
62
64
// We generate sourcemaps in production. This is slow but gives good results.
63
65
// You can exclude the *.map files from the build during deployment.
64
- devtool : 'source-map' ,
66
+ devtool : shouldUseSourceMap ? 'source-map' : false ,
65
67
target : 'electron-renderer' ,
66
68
// In production, we only want to load the polyfills and the app code.
67
69
entry : [ require . resolve ( './polyfills' ) , paths . appIndexJs ] ,
@@ -196,7 +198,7 @@ module.exports = {
196
198
options : {
197
199
importLoaders : 1 ,
198
200
minimize : true ,
199
- sourceMap : true ,
201
+ sourceMap : shouldUseSourceMap ,
200
202
} ,
201
203
} ,
202
204
{
@@ -292,7 +294,7 @@ module.exports = {
292
294
// https://github.com/facebookincubator/create-react-app/issues/2488
293
295
ascii_only : true ,
294
296
} ,
295
- sourceMap : true ,
297
+ sourceMap : shouldUseSourceMap ,
296
298
} ) ,
297
299
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
298
300
new ExtractTextPlugin ( {
0 commit comments