-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Rule with resourceQuery when there's no query #3497
Comments
You can workaround this with a |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
I also find this not very intuitive and using To avoid duplication I used [require.resolve('babel-plugin-transform-rename-import'), {
original: '^(.+)\\.svg$', replacement: '$1.svg?',
}], |
I ended up doing something like this for a similar issue I had. The fact that I had to move the specific files to a different folder didn't really help, but hey, at least it works. {
test: /\.svg$/,
oneOf: [
{
exclude: path.resolve(__dirname, 'images/svg/css-icons/'),
use: 'svg-inline-loader'
},
{
include: path.resolve(__dirname, 'images/svg/css-icons/'),
use: 'file-loader'
},
],
}, |
{
test: /\.(png|jpe?g|gif|svg)$/,
oneOf: [
{
resourceQuery: /inline/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'img/[name].[hash:7].[ext]'
}
},
{
loader: 'file-loader',
options: {
name: 'img/[name].[hash:7].[ext]'
}
}
]
}
May this config help you
|
It was requested I address this issue in #5906 |
same problem |
PR welcome |
@sokra Is this issue relevant to |
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
bump |
In case somebody else stumbles upon this looking to apply different loaders based on import path, the solution is pretty much what @calledT showcases in his answer. What's important though, is that you're not limited to using |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
@evilebottnawi such syntax is not possible with |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
It's impossible to perform a rule based on
resourceQuery
condition if a module has no query at all. That module won't pass directly.If the current behavior is a bug, please provide the steps to reproduce.
I have this case where there are resources of the same extension that some are loaded in a certain way an some in another. I can reach it using resource queries.
So I can write some config like this:
So I want that
.ext
files get loaded withnormal-loader
. Except the ones with?another
query, these will load withanother-loader
.But here's the result:
path/to/module.ext?another
: loaded withanother-loader
path/to/module.ext?asdfg
: loaded withnormal-loader
path/to/module.ext
: none, but we were naturally expectingnormal-loader
I guess there's a problem with the logic around here:
https://github.com/webpack/webpack/blob/v2.2.0-rc.0/lib/RuleSet.js#L361
It's skipping the condition and rejecting directly if
resourceQuery
is empty and there's a condition.What is the expected behavior?
It must be able to test a
resourceQuery
condition in an empty query.Please mention other relevant information such as the browser version, Node.js version, Operating System and programming language.
Node.js: v7.2.1
Webpack: v2.2.0-rc.0
The text was updated successfully, but these errors were encountered: