rocco
rocco

Reputation: 153

GENERATE_SOURCEMAP=false does not minifying .css files

I have a React application, and I've noticed that when I open Chrome Developer Tools and go to the Sources tab, I can see a folder named static/js. Expanding this folder reveals the entire code of my React project. This seems concerning from a security perspective.

So I went with the GENERATE_SOURCEMAP=false and it works for me for .js files only. I can still see the .css files in the Sources tab in static folder.

build: set \"GENERATE_SOURCEMAP=false\" && react-scripts build

How can I achieve to minify the css files? Does GENERATE_SOURCEMAP minifes js files only? How can I prevent the source code of my React app from being exposed in this manner? Is there a way to obfuscate or hide the code to enhance security?

Thanks in advance for your help!

Upvotes: 0

Views: 46

Answers (1)

 rocco
rocco

Reputation: 153

I achieved the result through the env file. I added one variable to .env file like below. After adding it to env file do not forget to update the env variable on your hosting platform as well. After adding this variable React will automatically take care of other things.

// .env

GENERATE_SOURCEMAP=false

Upvotes: 0

Related Questions