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

Last updated on December 2, 2020 A Goodman Loading... Post a comment

If you use create-react-app to initialize your React applications 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 .env file (environment file) in your project root directory and add the following to it:

GENERATE_SOURCEMAP=false

Related Articles

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x