I'm wondering how to generate source maps in create-react-app? are they done implicitly? and do they live in the build folder
I've read quite a lot about them being generated with webpack but my app is not using it, so I was wondering how I do this without webpack?
I also don't want to eject
A sourcemap is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of sourcemaps is to aid debugging. Basically, if there's an error in the generated code file, the map can tell you the original source file location. That's it.
In the inspection tool, click on the gear icon on the very top right of the window to open the settings page as shown below. In the preference tab, under the Sources subheader, make sure that Enable JavaScript source maps is enabled.
A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.
According to CRA documentation, source maps are generated by default in production mode.
However, you can disable this behavior (generating source maps in production mode) by running GENERATE_SOURCEMAP=false ./node_modules/.bin/react-scripts build
or if you want this behavior to be permanent, do one of the following solutions:
"build": "react-scripts build"
with "build": "GENERATE_SOURCEMAP=false react-scripts build"
https://facebook.github.io/create-react-app/docs/advanced-configuration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With