>= 0.2.0
Used to set whether to generate source map files, and which format of source map to generate.
Source map is an information file that saves the source code mapping relationship. It records each location of the compiled code and the corresponding pre-compilation location. With source map, you can directly view the source code when debugging the compiled code.
By default, the source map generation rules for Rsbuild are as follows:
The source map for JS files is controlled by sourceMap.js
and can be configured by passing in all the source map formats supported by Rspack's devtool option. Setting it to false
will disable the source map.
For example, if you need to generate high-quality source maps in all environments, you can set it as follows:
You can also set different source map formats based on the environment.
The source map for CSS files is controlled by sourceMap.css
. Setting it to true
will enable the source map, while setting it to false
will disable it.
For example, if you need to generate a source map for CSS files, you can set it as follows: