How to get rid of Source Maps when building a React project
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:
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"
"build": "GENERATE_SOURCEMAP=false react-scripts build"
2. Create .env file (environment file) in your project root directory and add the following to it: