Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the original source code is showing in the source using webpack? And how to disable it?

I am using Facebook's 'create-react-app' template to create my project, after I deployed it to server, I find out that I can view the source code via:

Chrome > Console > Sources > webpack://

Is this possible to disable it? Thanks.

enter image description here

like image 990
DNB5brims Avatar asked Nov 08 '22 23:11

DNB5brims


1 Answers

  1. Eject your create-react-app by running npm run eject
  2. Open /config/webpack.config.prod.js
  3. Remove or comment out line 53 containing devtool: 'source-map',
  4. Build, and deploy your app again

Ironically, the annotations inside of /config/webpack.config.prod.js admit generating sourcemaps in production "is slow but gives good results". I'm not sure what good results means but theres your fix.

like image 200
Nick Sarafa Avatar answered Nov 14 '22 21:11

Nick Sarafa