create-react-app is showing all my code in production, how to hide it?

It seems to be correct behaviour in create-react-app according to Issue #1632.

Gaeron:

This is expected. You can delete .map files from the build output if
you want to disable it, although you’ll get console warnings about
them missing.

There is no harm in leaving them in though in my opinion. Client code
is already available to the user’s machine so there’s no secrets in
it.

Also ensure you have proper production build, the output of npm run build/yarn build is the one which should be deployed to your server.

If you want to completely disable generation of source maps use:

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

You can also specify GENERATE_SOURCEMAP=false parameter via .env configuration files or use in plain console command GENERATE_SOURCEMAP=false react-scripts build.

Leave a Comment