@@ -605,12 +605,19 @@ module.exports = {
605605Type:
606606
607607``` 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 );
609616```
610617
611618Default: ` undefined `
612619
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.
614621
615622Possible values:
616623
@@ -673,7 +680,7 @@ module.exports = {
673680
674681###### ` function `
675682
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.
677684
678685** webpack.config.js**
679686
@@ -686,7 +693,9 @@ module.exports = {
686693 loader: " css-loader" ,
687694 options: {
688695 modules: {
689- auto : (resourcePath ) => resourcePath .endsWith (" .custom-module.css" ),
696+ auto : (resourcePath , resourceQuery , resourceFragment ) => {
697+ return resourcePath .endsWith (" .custom-module.css" );
698+ },
690699 },
691700 },
692701 },
@@ -705,7 +714,11 @@ type mode =
705714 | " global"
706715 | " pure"
707716 | " icss"
708- | ((resourcePath : string ) => " local" | " global" | " pure" | " icss" );
717+ | ((
718+ resourcePath : string ,
719+ resourceQuery : string ,
720+ resourceFragment : string
721+ ) => " local" | " global" | " pure" | " icss" );
709722```
710723
711724Default: ` 'local' `
@@ -745,7 +758,7 @@ module.exports = {
745758
746759###### ` function `
747760
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.
749762
750763Possible return values - ` local ` , ` global ` , ` pure ` and ` icss ` .
751764
@@ -761,7 +774,7 @@ module.exports = {
761774 options: {
762775 modules: {
763776 // Callback must return "local", "global", or "pure" values
764- mode : (resourcePath ) => {
777+ mode : (resourcePath , resourceQuery , resourceFragment ) => {
765778 if (/ pure. css$ / i .test (resourcePath)) {
766779 return " pure" ;
767780 }
0 commit comments