question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to remove sourcemap line in built assets?

See original GitHub issue

Similar question here: https://github.com/facebookincubator/create-react-app/issues/1004.

Is a nice way to remove the sourcemap line from the .js and .css files?

I’m tossing up between looking for the sourcemap pattern (//# sourcemap etc) and removing the match or ejecting to remove it from the webpack config, though that seems drastic for such a minor change.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

46reactions
SanichKotikovcommented, Dec 21, 2017

GENERATE_SOURCEMAP=false react-scripts build doesn’t work?

40reactions
shrynxcommented, Jan 3, 2017

@tbillington @gaearon you can add a postbuild or (pre in case of gh-pages ,etc) script to your package.json and use rimraf to remove the files.

   // package.json
  ...

  "scripts": {
     ...
      
     "build": "react-scripts build",
     "postbuild": "rimraf build/**/*.map",

      ...
  }

The //# sourcemap line will give warning source map not found on dev console though. Removing this would be little troublesome but can be totally done using postbuild script. you can create a script using decomment and run it as part of postbuild or (prepublish, etc)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable source maps for React JS Application
This way, it will auto delete map files during build generation. ... Go to /config/webpack.config.js directory and change the following line ...
Read more >
Source Maps - Parcel
If you're writing a custom packager, it's your responsibility to concatenate the source maps of all the assets while packaging. This is done...
Read more >
Source maps and how it works - Ehsan Gazar
Using Webpack, specifying devtool: "source-map" in your Webpack config will enable source maps, and Webpack will output a sourceMappingURL ...
Read more >
Should I Use Source Maps in Production? | CSS-Tricks
It's a valid question. A "source map" is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to...
Read more >
SourceMapDevToolPlugin - webpack
If you want to use a custom configuration for this plugin in development mode, make sure to disable the default one. I.e. set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found