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

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.



Solution 1:[1]

Prepend your build script with GENERATE_SOURCEMAP=false:

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

Solution 2:[2]

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

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

Solution 3:[3]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fellow Stranger
Solution 2 Venky
Solution 3 Morlo Mbakop