-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Support [query] in interpolateName #154
Conversation
Seems that |
lib/interpolateName.js
Outdated
@@ -52,6 +52,9 @@ function interpolateName(loaderContext, name, options) { | |||
let basename = 'file'; | |||
let directory = ''; | |||
let folder = ''; | |||
const query = loaderContext.resourceQuery | |||
? loaderContext.resourceQuery.substr(1) | |||
: ''; |
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 think we can solve this in easy way, like:
const queryStringIdx = targetFile.indexOf('?');
let query = '';
if (queryStringIdx >= 0) {
query= targetFile.slice(queryStringIdx);
}
without
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 not quite sure if I understood correctly. As far as I understand, the resourcePath
and resourceQuery
are two separate entities. I can't split the path by ?
, but I was trying to remove the leading ?
character. I updated the code to be a bit more verbose. I hope this is what you meant.
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.
Logic is simple, if name
contains ?foo=bar
we interpreted this as [query]
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.
Could you elaborate on which name
you mean? I can only get ?foo=bar
from loaderContext.resourceQuery
. I feel like I'm missing something.
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.
name
- second argument for interpolateName
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.
Good job, one note
Just for information, we move loader-utils logic inside webpack@5, so this module will be deprecated |
Need fix CI Problem |
I found an issue on the error that Yarn is throwing in CI: yarnpkg/yarn#6619 (comment) |
@evilebottnawi Anything I can help with? I can update For what it's worth, I can run the Jest test suite in Node 4 and everything passes. |
Actually, I checked a bit better and see that ESLint isn't even running in CI. It's just the |
@pajter ignore problem with node@4 |
Is this okay to merge then? |
Done in master, sorry for delay, really sorry |
This PR adds support for
[query]
in the template ofinterpolateName
.Some background: I want to load SVG files in CSS but pass query parameters to them to influence SVG properties such as
fill
etc. After some digging I found out thatfile-loader
uses theinterpolateName
function in this lib, and that there's no way to use[query]
in the template. Seemed to me like this would be nice to have and easy enough to support.I'd love to get your feedback on this. Please let me know if there's anything I missed!