Is there any way to disable generating of SourceMaps for production build?
CRA has .env variable called - GENERATE_SOURCEMAP.
I cannot see anything in docs. So, I suppose, the only possible way is to extend webpack config inside razzle.config.js?
extend webpack config inside razzle.config.js
This is the solution. An example razzle.config.js.
module.exports = {
modify: (config, { target, dev }) => {
config.devtool = dev ? 'source-map' : false;
return config;
},
};
@krazyjakee yes that what I was talking about and I have the same in my code right now.
But this is a bit overcomplicated as for me to achieve such a goal. Not too accurate, to be honest.
Prefer the CRA way to do it.
However, if it is the only possible way then ok.
@Ronny25 If you really want to use environment variables you could do something like:
module.exports = {
modify: config => {
config.devtool = process.env.GENERATE_SOURCEMAP ? 'source-map' : false;
return config;
},
};
Then you get the same accuracy as CRA.
@krazyjakee that's not completely true 馃槃
Firstly, you need to create a config file with some logic inside then an env variable, sounds strange 馃槈
But I can live with is 馃榿
@krazyjakee
This only seems to disable source maps for .js files.
.css files still get source map files generated.
Most helpful comment
@krazyjakee
This only seems to disable source maps for .js files.
.css files still get source map files generated.