Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
When I run
npm run build
in my react app I get the following warning:
static/js/widget.js contains invalid source map
.
When I remove the UglifyJs settings in my webpack config the build process passes without any warnings.
My Webpack config (only parts which are relevant regarding the sourcemap):
// Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
module.exports = {
// Don't attempt to continue if there are any errors.
bail: true,
mode: 'production',
// We generate sourcemaps in production. This is slow but gives good results.
// You can exclude the *.map files from the build during deployment.
devtool: shouldUseSourceMap ? 'source-map' : false,
plugins: [
new UglifyJsPlugin({
uglifyOptions: {
sourceMap: shouldUseSourceMap,
warnings: false,
compress: {
comparisons: false
output: {
comments: false,
ascii_only: true
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.