Issue
After using npm run build
cmd with the following script in package.json file in my React App,
"scripts": {
"start": "react-scripts start",
"build": "set 'GENERATE_SOURCEMAP=false' && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
FYI: I am using windows machine.
The js code is not hiding from the browser stil I can see from the browser sources tab. I am using spring application as backend.
Can anyone tell me how can I do hide js file or minify it after prod build.
Solution
Based on comments that I receive form this post, I do the following and it resolve my problem, 1.Create .env file in my React project,
2.In this env file m I just put the following
BUILD_PATH='<location where I need to put the build content>'
GENERATE_SOURCEMAP=false
3.Simply run npm run build
it will generate the minified build and placed it mentioned location in the .env file.
Since it is minified the js content , So in DEV env , I just set GENERATE_SOURCEMAP=true
to debug the code if needed.
Answered By - Subrata Ghosh
Answer Checked By - Mildred Charles (JavaFixing Admin)