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:
- React + TypeScript: Re-render a Component on Window Resize
- React + TypeScript: Handling onScroll event
- React: Show Image Preview before Uploading
- React: Get the Width & Height of a dynamic Element
- Most popular React Component UI Libraries
- React: Create an Animated Side Navigation from Scratch
You can also check our React category page and React Native category page for the latest tutorials and examples.