Why I see the source code of my React app in the production build and how to hide it?
Introduction
As a backend developer, it's a given that my code is not visible inside the browser.
However, I was shocked when I saw the source code of my React app in the production build via the dev tools in the console.
Reason:
By default, a React app generates source map files in the production build which help in debugging.
You will not find the source code inside the /build folder.
Solution:
Add below line in your package.json
file
package.json
"scripts": {
+ "build": "GENERATE_SOURCEMAP=false react-scripts build"
}
This will hide your source code in the production build.