File tree Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,12 @@ function mergeWithRule({
192192 ret [ k ] = v . concat ( appendValue ) ;
193193 break ;
194194 case CustomizeRule . Merge :
195+ if ( ! bMatches . length ) {
196+ ret [ k ] = v ;
197+
198+ break ;
199+ }
200+
195201 const lastValue = last ( bMatches ) [ k ] ;
196202
197203 if ( ! isPlainObject ( v ) || ! isPlainObject ( lastValue ) ) {
Original file line number Diff line number Diff line change @@ -1043,4 +1043,78 @@ describe("Merge with rules", function () {
10431043 } ) ( base , development )
10441044 ) . toEqual ( result ) ;
10451045 } ) ;
1046+
1047+ it ( "should fall back to default behavior without a match when merging (#167)" , function ( ) {
1048+ const conf1 = {
1049+ module : {
1050+ rules : [
1051+ {
1052+ test : "/\\.scss$|\\.sass$/" ,
1053+ use : [
1054+ {
1055+ loader : "sass-loader" ,
1056+ options : {
1057+ sourceMap : true ,
1058+ } ,
1059+ } ,
1060+ ] ,
1061+ } ,
1062+ ] ,
1063+ } ,
1064+ } ;
1065+ const conf2 = {
1066+ module : {
1067+ rules : [
1068+ {
1069+ test : "/\\.scss$|\\.sass$/" ,
1070+ use : [
1071+ {
1072+ loader : "sass-resources-loader" ,
1073+ options : {
1074+ resources : [ "src/styles/includes.scss" ] ,
1075+ } ,
1076+ } ,
1077+ ] ,
1078+ } ,
1079+ ] ,
1080+ } ,
1081+ } ;
1082+ const result = {
1083+ module : {
1084+ rules : [
1085+ {
1086+ test : "/\\.scss$|\\.sass$/" ,
1087+ use : [
1088+ {
1089+ loader : "sass-loader" ,
1090+ options : {
1091+ sourceMap : true ,
1092+ } ,
1093+ } ,
1094+ {
1095+ loader : "sass-resources-loader" ,
1096+ options : {
1097+ resources : [ "src/styles/includes.scss" ] ,
1098+ } ,
1099+ } ,
1100+ ] ,
1101+ } ,
1102+ ] ,
1103+ } ,
1104+ } ;
1105+
1106+ expect (
1107+ mergeWithRules ( {
1108+ module : {
1109+ rules : {
1110+ test : CustomizeRule . Match ,
1111+ use : {
1112+ loader : CustomizeRule . Match ,
1113+ options : CustomizeRule . Merge ,
1114+ } ,
1115+ } ,
1116+ } ,
1117+ } ) ( conf1 , conf2 )
1118+ ) . toEqual ( result ) ;
1119+ } ) ;
10461120} ) ;
You can’t perform that action at this time.
0 commit comments