Categories
JavaScript Answers

How to disable source maps for React application?

Spread the love

To disable source maps for React application, we set the GENERATE_SOURCEMAP environment variable to false.

For instance, in package.json, we write

{
  "scripts": {
    "start": "react-scripts start",
    "build": "GENERATE_SOURCEMAP=false react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

to set the GENERATE_SOURCEMAP environment variable to false before running react-scripts build to disable source map generation in the build script.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *