When does create-react-app obfuscate or minify code?

Kyle Pennell picture Kyle Pennell · Mar 6, 2018 · Viewed 29.9k times · Source

I have kind of a basic question about webpack and react that I can use help with (around code obfuscation/uglification).

I am using create-react-app for my application and it appears to create a bundled build for production (after running yarn build).

And in that file it seems that everything is put into a main.JS file and main.CSS file Etc. I push this live using "firebase deploy" (in my case). I would like my code to be uglified and not be completely readable by any developer out there.

But when I go to look at my apps in Chrome it doesn't show main.JS or any other of the bundles files. It just shows every single individual file and exactly the code that I've written. Any idea why this is? Why doesn't it show the uglified combined main.js file under the 'sources' tab in chrome? Is this to do with the source map?

Answer

Viacheslav Luschinskiy picture Viacheslav Luschinskiy · Jul 11, 2018

There is a better way to make sure source maps are not included. Create .env file in your project root folder and add GENERATE_SOURCEMAP=false. You will get you build without source maps.