@@ -362,4 +362,70 @@ describe('parseCommonConfig', () => {
362
362
} ) ;
363
363
}
364
364
} ) ;
365
+
366
+ describe ( 'CSS source map configuration' , ( ) => {
367
+ test ( 'should not set css source map when output.sourceMap is true' , async ( ) => {
368
+ const config = await parseCommonConfig ( {
369
+ output : {
370
+ sourceMap : true ,
371
+ } ,
372
+ } ) ;
373
+
374
+ expect ( config . rsbuildConfig . output ?. sourceMap ) . toBe ( true ) ;
375
+ expect ( config . rsbuildConfig . output ?. sourceMap ) . not . toHaveProperty ( 'css' ) ;
376
+ } ) ;
377
+
378
+ test ( 'should set css source map to false when output.sourceMap is false' , async ( ) => {
379
+ const config = await parseCommonConfig ( {
380
+ output : {
381
+ sourceMap : false ,
382
+ } ,
383
+ } ) ;
384
+
385
+ expect ( config . rsbuildConfig . output ?. sourceMap ) . toEqual ( false ) ;
386
+ } ) ;
387
+
388
+ test ( 'should set css source map to false when output.sourceMap.css is explicitly false' , async ( ) => {
389
+ const config = await parseCommonConfig ( {
390
+ output : {
391
+ sourceMap : {
392
+ css : false ,
393
+ } ,
394
+ } ,
395
+ } ) ;
396
+
397
+ expect ( config . rsbuildConfig . output ?. sourceMap ) . toEqual ( {
398
+ css : false ,
399
+ } ) ;
400
+ } ) ;
401
+
402
+ test ( 'should set css source map to true when output.sourceMap is undefined in development' , async ( ) => {
403
+ process . env . NODE_ENV = 'development' ;
404
+
405
+ const config = await parseCommonConfig ( {
406
+ output : { } ,
407
+ } ) ;
408
+
409
+ expect ( config . rsbuildConfig . output ?. sourceMap ) . toEqual ( {
410
+ css : true ,
411
+ } ) ;
412
+ } ) ;
413
+
414
+ test ( 'should respect explicitly set css source map in development' , async ( ) => {
415
+ process . env . NODE_ENV = 'development' ;
416
+
417
+ const config = await parseCommonConfig ( {
418
+ output : {
419
+ sourceMap : {
420
+ css : false ,
421
+ } ,
422
+ } ,
423
+ } ) ;
424
+
425
+ // Even in development, if explicitly set to false, it should remain false
426
+ expect ( config . rsbuildConfig . output ?. sourceMap ) . toEqual ( {
427
+ css : false ,
428
+ } ) ;
429
+ } ) ;
430
+ } ) ;
365
431
} ) ;
0 commit comments