@@ -605,12 +605,19 @@ module.exports = {
605
605
Type:
606
606
607
607
``` ts
608
- type auto = boolean | regExp | ((resourcePath : string ) => boolean );
608
+ type auto =
609
+ | boolean
610
+ | regExp
611
+ | ((
612
+ resourcePath : string ,
613
+ resourceQuery : string ,
614
+ resourceFragment : string
615
+ ) => boolean );
609
616
```
610
617
611
618
Default: ` undefined `
612
619
613
- Allows auto enable CSS modules/ICSS based on filename when ` modules ` option is object.
620
+ Allows auto enable CSS modules/ICSS based on the filename, query or fragment when ` modules ` option is object.
614
621
615
622
Possible values:
616
623
@@ -673,7 +680,7 @@ module.exports = {
673
680
674
681
###### ` function `
675
682
676
- Enable CSS modules for files based on the filename satisfying your filter function check.
683
+ Enable CSS modules for files based on the filename, query or fragment satisfying your filter function check.
677
684
678
685
** webpack.config.js**
679
686
@@ -686,7 +693,9 @@ module.exports = {
686
693
loader: " css-loader" ,
687
694
options: {
688
695
modules: {
689
- auto : (resourcePath ) => resourcePath .endsWith (" .custom-module.css" ),
696
+ auto : (resourcePath , resourceQuery , resourceFragment ) => {
697
+ return resourcePath .endsWith (" .custom-module.css" );
698
+ },
690
699
},
691
700
},
692
701
},
@@ -705,7 +714,11 @@ type mode =
705
714
| " global"
706
715
| " pure"
707
716
| " icss"
708
- | ((resourcePath : string ) => " local" | " global" | " pure" | " icss" );
717
+ | ((
718
+ resourcePath : string ,
719
+ resourceQuery : string ,
720
+ resourceFragment : string
721
+ ) => " local" | " global" | " pure" | " icss" );
709
722
```
710
723
711
724
Default: ` 'local' `
@@ -745,7 +758,7 @@ module.exports = {
745
758
746
759
###### ` function `
747
760
748
- Allows set different values for the ` mode ` option based on a filename
761
+ Allows set different values for the ` mode ` option based on the filename, query or fragment.
749
762
750
763
Possible return values - ` local ` , ` global ` , ` pure ` and ` icss ` .
751
764
@@ -761,7 +774,7 @@ module.exports = {
761
774
options: {
762
775
modules: {
763
776
// Callback must return "local", "global", or "pure" values
764
- mode : (resourcePath ) => {
777
+ mode : (resourcePath , resourceQuery , resourceFragment ) => {
765
778
if (/ pure. css$ / i .test (resourcePath)) {
766
779
return " pure" ;
767
780
}
0 commit comments