Kinda Code
Home/React/How to get rid of Source Maps when building a React project

How to get rid of Source Maps when building a React project

Last updated: February 13, 2023

If you use create-react-app to initialize your React application, then source map files are generated by default when you build production code with the following command:

yarn build

or:

npm run build 

In general, you can find the source map files (with the map extension) in build/static/css and build/static/js, like this:

Source maps are super helpful in debugging but if don’t want them to come, you can use one of the following methods:

1. Change the build command in your package.json file from this:

"build": "react-scripts build"

To this:

"build": "GENERATE_SOURCEMAP=false react-scripts build"

2. Create a .env file (environment file) in your project root directory and add the following to it:

GENERATE_SOURCEMAP=false

That’s it. Further reading:

You can also check our React category page and React Native category page for the latest tutorials and examples.

Related Articles