-
-
Notifications
You must be signed in to change notification settings - Fork 283
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(processPattern): add support for {RegExp)
matches (pattern.test
)
#235
Conversation
Actually, trying to make sure that templates are supported in the returned value. |
toType
"function"{RegExp)
matches (patterns.toRegExp
)
{RegExp)
matches (patterns.toRegExp
){RegExp)
matches (pattern.toRegExp
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor renaming pattern.toRegExp
=> pattern.test
instead
README.md
Outdated
@@ -138,6 +138,9 @@ Or, in case of just a `from` with the default destination, you can also use a `{ | |||
from: 'src/' | |||
to: 'dest/[name].[hash].[ext]', | |||
toType: 'template' | |||
// Optional: provide a regExp to extract additional placeholders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make a new 'section' for this option, or does it only work with toType: 'template'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs to be added to options
table please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will only work with the template toType
. Will update the table.
{RegExp)
matches (pattern.toRegExp
){RegExp)
matches (pattern.test
)
Would it make sense to use |
|
@jkrems rebase 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Rebase'd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor important nitpicks, please rebase :)
README.md
Outdated
@@ -143,6 +144,27 @@ Or, in case of just a `from` with the default destination, you can also use a `{ | |||
] | |||
``` | |||
|
|||
### `test` | |||
|
|||
Defines a regExp to match some parts of the file path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regExp
=> {RegExp}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
README.md
Outdated
|
||
Defines a regExp to match some parts of the file path. | ||
These capture groups can be reused in the name property using `[N]` placeholder. | ||
Note that `[0]` will be replaced by the entire tested string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> ℹ️ Note
string
=> {String}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with "entire relative path of the file" while I was touching it since that seemed easier to understand than what the "tested string" was.
README.md
Outdated
Defines a regExp to match some parts of the file path. | ||
These capture groups can be reused in the name property using `[N]` placeholder. | ||
Note that `[0]` will be replaced by the entire tested string, | ||
whereas `[1]` will contain the first capturing parenthesis of your regex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex
=> {RegExp}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Alright, the arguments to the interpolate call changed (relative -> absolute). Updated the test and docs to match that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkrems Thx
Released in |
Niiice! That was fast! Thanks a lot for the quick review & release. :) |
We want to match some of our existing asset logic which generates image file names from the source paths. Having a function that generates those paths seemed like the simplest solution.
This mirrors the way the
file-loader
works, allowing to reuse logic. https://github.com/webpack-contrib/file-loader#regexp