Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

showing_all_files

In my chrome sources tab, I am able to view all my files by exact folder location. How can I hide them?

These weren't the problem in my previous project, which were made without using create-react-app.

like image 639
Sabbiu Shah Avatar asked Jul 19 '18 06:07

Sabbiu Shah


People also ask

How do I completely remove create-React-app?

If you've previously installed create-react-app globally via npm install -g create-react-app , we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version. Then open http://localhost:3000/ to see your app.

Can users see my React code?

Do you know that when you deploy your React application which is created using create-react-app or your own webpack configuration to a live website like Netlify, Vercel, Heroku etc, your entire source code is visible to everyone from the sources tab of the dev tools.


1 Answers

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.

like image 83
Xarvalus Avatar answered Sep 21 '22 16:09

Xarvalus