Skip to content

Commit da3b2ca

Browse files
committed
feat: support regex in filter
Makes running css-loader with advanced filter settings in worker possible.
1 parent 12b7d98 commit da3b2ca

File tree

5 files changed

+5378
-3301
lines changed

5 files changed

+5378
-3301
lines changed

src/options.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
"type": "object",
1414
"properties": {
1515
"filter": {
16-
"instanceof": "Function"
16+
"description": "Allows to custom `url()`/`image-set()` functions handling via regexp or function.",
17+
"link": "https://github.com/webpack-contrib/css-loader#url",
18+
"anyOf": [
19+
{
20+
"instanceof": "RegExp"
21+
},
22+
{
23+
"instanceof": "Function"
24+
}
25+
]
1726
}
1827
},
1928
"additionalProperties": false

src/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,9 @@ function getFilter(filter, resourcePath) {
529529
if (typeof filter === "function") {
530530
return filter(...args, resourcePath);
531531
}
532-
532+
if (filter instanceof RegExp) {
533+
return filter.exec(...args);
534+
}
533535
return true;
534536
};
535537
}

0 commit comments

Comments
 (0)