Here is my use case: Most svgs should be inlined. Therefore, I set the rule as follows:
{test: /\.svg$/, use: "svg-inline-loader"},
In some cases, I just want the svg url and not embed it. In webpack 1.x, I required them like this: require('path/to/file.svg?external') .
Here's the corresponding rule:
{test: /\.svg\?external$/, use: "file-loader!image-webpack-loader"},
Does webpack 2 seem to no longer include a part ? when test ing for the rule, since only the first rule applies to all my svgs after migration.
Is there any way around this? Is there a different strategy for using different sets of downloaders for files of the same extension when require them?
PS: I know that I might need a file like this: require('!file-loader!image-webpack-loader!path/to/file.svg') , but my bootloaders are a bit more complicated than that, and I don’t want to constantly repeat their configuration.
PSS: This does not seem to work (it only applies to the first rule)
{test: /\.svg$/, use: "svg-inline-loader", exclude: /\?external/}, {test: /\.svg$/, use: "file-loader?!image-webpack-loader", include: /\?external/}
webpack webpack-2
Daniel
source share