ReactJS remove sourcemap files after build
I’m creating ReactJS applications using “create-react-app” command. Then it creating a fresh react application and I’m using it. I’m coding and coding then building with “npm run build” command. Everything is nice until here but there is a problem after finishing build. It creating a map file under build/static/js/main.[uniquid].map file and this is unnecessary and huge.
Why is this creating I don’t know (probably it’s purpose is debugging in browser). I don’t want it in production. Nobody will use this file. I don’t want that shit file. I googled this issue and found a solution. The solution is in HERE.
In short way solution is that: insert a script for after build and delete unnecessary files. For this there is two things to do.
- Install “rimraf” library globally with “npm“: sudo npm install rimraf -g
- Add this line to your package.json file after “build” line: “postbuild”: “rimraf build/**/*.map”,
That’s all. After this time you don’t have to load that shit “map” file to FTP or browser. Have a nice day.
0 yorum