Is is possible to disable source-maps in create-react-app without having to eject

Viewed 4824

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.

3 Answers

Prepend your build script with GENERATE_SOURCEMAP=false:

"build": "GENERATE_SOURCEMAP=false react-scripts build"

Yes. We can remove by adding a post build command like

yarn build && rm build/static/js/*.map && rm build/static/css/*.map

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.

Related