@@ -32,6 +32,11 @@ export const pluginSourceMap = (): RsbuildPlugin => ({
3232 absoluteResourcePath : string ;
3333 } ) => absoluteResourcePath ;
3434
35+ const enableCssSourceMap = ( config : NormalizedEnvironmentConfig ) => {
36+ const { sourceMap } = config . output ;
37+ return typeof sourceMap === 'object' && sourceMap . css ;
38+ } ;
39+
3540 api . modifyBundlerChain ( ( chain , { bundler, environment } ) => {
3641 const { config } = environment ;
3742 const devtool = getDevtool ( config ) ;
@@ -42,8 +47,7 @@ export const pluginSourceMap = (): RsbuildPlugin => ({
4247
4348 // When JS source map is disabled, but CSS source map is enabled,
4449 // add `SourceMapDevToolPlugin` to let Rspack generate CSS source map.
45- const { sourceMap } = config . output ;
46- if ( ! devtool && typeof sourceMap === 'object' && sourceMap . css ) {
50+ if ( ! devtool && enableCssSourceMap ( config ) ) {
4751 chain . plugin ( 'source-map-css' ) . use ( bundler . SourceMapDevToolPlugin , [
4852 {
4953 test : / \. c s s $ / ,
@@ -61,6 +65,14 @@ export const pluginSourceMap = (): RsbuildPlugin => ({
6165 // Source maps has been extracted to separate files on this stage
6266 { stage : 'optimize-transfer' } ,
6367 ( { assets, compilation, sources, environment } ) => {
68+ // If source map is disabled, skip the processing.
69+ if (
70+ ! compilation . options . devtool &&
71+ ! enableCssSourceMap ( environment . config )
72+ ) {
73+ return ;
74+ }
75+
6476 // If devtoolModuleFilenameTemplate is not the default template,
6577 // which means users want to customize it, skip the default processing.
6678 if (
0 commit comments