Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of the webpack source code on client side?

I deploy a node.js app on pm2 server which serves my client code with Nginx. My client source code is bundled with Webpack. It is supposed to be minified and obfuscated. But when I run my app on client side and I open the console log "source" tab I can see both the obfuscated source code and the webpack file structure which is located under a "top://Webpack" directory.

I don't want to show my code structure to the client. How can I get rid of that webpack file structure on the browser?

like image 227
newguy Avatar asked Oct 20 '25 07:10

newguy


1 Answers

This original file structure is provided by sourcemaps. Which is great because allows you to trace back errors in production code.

You have the following options here

  • Disable sourcemaps generation by setting devtool: false Docs.
  • Do not serve *.map files by removing them or by configuring nginx not to serve those files.

You could read a discussion why this is not that great idea here

like image 171
Yury Tarabanko Avatar answered Oct 21 '25 22:10

Yury Tarabanko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!