Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support regex in filter #1555

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/options.json
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
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