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