My react folder structure is as below
I\'ve not used the create-react-app version. I tried using GENERATE_SOURCEMAP=false
. But It didn\'t work.
This works for me. Hope it helps anyone.
// package.json
"build": "react-scripts build",
"postbuild": "rimraf build/**/*.map"
This way, it will auto delete map files during build generation.
Edit you package.json
like below:
"scripts": {
"start": "react-scripts start",
"build": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"scripts": {
"start": "react-scripts start",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
This solution is not operating system dependent and works on both Linux and Windows. Just create a file called .env
and add the following line to it:
GENERATE_SOURCEMAP=false