File tree Expand file tree Collapse file tree 4 files changed +19
-12
lines changed Expand file tree Collapse file tree 4 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -414,15 +414,22 @@ export const pluginCss = (): RsbuildPlugin => ({
414414 } ) ;
415415
416416 updateRules ( ( rule , type ) => {
417- rule . use ( CHAIN_ID . USE . CSS ) . options (
418- type === 'inline'
419- ? ( {
420- ...cssLoaderOptions ,
421- exportType : 'string' ,
422- modules : false ,
423- } satisfies CSSLoaderOptions )
424- : cssLoaderOptions ,
425- ) ;
417+ let finalOptions = cssLoaderOptions ;
418+
419+ if ( type === 'inline' ) {
420+ finalOptions = {
421+ ...cssLoaderOptions ,
422+ exportType : 'string' ,
423+ modules : false ,
424+ } ;
425+ } else if ( ! emitCss && cssLoaderOptions . importLoaders ) {
426+ // If emitCss is disabled, correct importLoaders number for normal CSS rule
427+ finalOptions = {
428+ ...cssLoaderOptions ,
429+ importLoaders : cssLoaderOptions . importLoaders - 1 ,
430+ } ;
431+ }
432+ rule . use ( CHAIN_ID . USE . CSS ) . options ( finalOptions ) ;
426433
427434 // CSS imports should always be treated as sideEffects
428435 rule . sideEffects ( true ) ;
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ exports[`plugin-css injectStyles > should apply ignoreCssLoader when injectStyle
133133 {
134134 " loader" : " <ROOT>/packages/core/compiled/css-loader/index.js" ,
135135 " options" : {
136- " importLoaders" : 1 ,
136+ " importLoaders" : 0 ,
137137 " modules" : {
138138 " auto" : true ,
139139 " exportGlobals" : false ,
Original file line number Diff line number Diff line change @@ -1136,7 +1136,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
11361136 {
11371137 " loader" : " <ROOT>/packages/core/compiled/css-loader/index.js" ,
11381138 " options" : {
1139- " importLoaders" : 1 ,
1139+ " importLoaders" : 0 ,
11401140 " modules" : {
11411141 " auto" : true ,
11421142 " exportGlobals" : false ,
Original file line number Diff line number Diff line change @@ -1966,7 +1966,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
19661966 {
19671967 " loader" : " <ROOT>/packages/core/compiled/css-loader/index.js" ,
19681968 " options" : {
1969- " importLoaders" : 1 ,
1969+ " importLoaders" : 0 ,
19701970 " modules" : {
19711971 " auto" : true ,
19721972 " exportGlobals" : false ,
You can’t perform that action at this time.
0 commit comments