Was wondering was it possible to disable source-maps in create-react-app without having to eject. Guessing once you eject from create-react-app you can disable source-maps in webpack.
Asked
Active
Viewed 6,006 times
3
-
1Thought these solution might be useful anyone else runs into this issue as I could not find any similar solutions on stackoverflow. Have 2 initial solutions that I found to work. 1. adding GENERATE_SOURCEMAP=true into the build script in the package.json file. 2. adding GENERATE_SOURCEMAP=false to the .env.production file also prevented source maps being added to my production build. hope this is of some help to someone. – uidevthing Aug 30 '18 at 10:10
3 Answers
4
Prepend your build
script with GENERATE_SOURCEMAP=false
:
"build": "GENERATE_SOURCEMAP=false react-scripts build"

Fellow Stranger
- 32,129
- 35
- 168
- 232
2
Yes. We can remove by adding a post build command like
yarn build && rm build/static/js/*.map && rm build/static/css/*.map

Venky
- 31
- 6
1
As per create-react-app doc you can create a .env file at the root of your project and add this:
GENERATE_SOURCEMAP = false
It will only remove source map for production build.

Morlo Mbakop
- 3,518
- 20
- 21