Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: support regex in filter
Makes running css-loader with advanced filter settings in worker possible.
  • Loading branch information
janlent1 committed Dec 11, 2023
commit da3b2cae252ca1a6808ff1a199920f0cedb7ef0e
11 changes: 10 additions & 1 deletion src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
"type": "object",
"properties": {
"filter": {
"instanceof": "Function"
"description": "Allows to custom `url()`/`image-set()` functions handling via regexp or function.",
"link": "https://github.com/webpack-contrib/css-loader#url",
"anyOf": [
{
"instanceof": "RegExp"
},
{
"instanceof": "Function"
}
]
}
},
"additionalProperties": false
Expand Down
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ function getFilter(filter, resourcePath) {
if (typeof filter === "function") {
return filter(...args, resourcePath);
}

if (filter instanceof RegExp) {
return filter.exec(...args);
}
return true;
};
}
Expand Down
Loading