Do you want to request a feature, report a bug or ask a question?
Question
What is the current behavior?
Svg is doesn't get imported when extract: true
What is the expected behavior?
Svg gets imported.
The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code).
https://gist.github.com/srosca/80932a82e55e90c8409c6a6dc09f7e51
Please tell us about your environment:
@srosca I need a whole package.json and build script to reproduce a problem
the same error with me
TypeError: Cannot read property 'options' of undefined
at getLoaderOptions (/Users/.../node_modules/svg-sprite-loader/lib/utils/get-loader-options.js:26:80)
it looks the root case is in get-matched-rules.js
@kisenka
Could someone make a PR?
I've got the same issue here. @kisenka, is there any additional information you'd like to see?
Thanks for all your work on this plugin by the way!
Also stumbled upon this, we replaced extract-text-webpack-plugin with mini-css-extract-plugin and now the svg urls in our css files are replaced by absolute path to the svg file itself instead of url to the svg sprite.
Update: Mine problem sounds more like https://github.com/kisenka/svg-sprite-loader/issues/294 - or maybe its the same thing?
I'm seeing the same error as @rguanghui while attempting to upgrade our build process from Webpack 3 to 4, during which I've also switched to mini-css-extract-plugin (just like @martinkadlec0). However - the symptom I'm experiencing is that the entire webpack build crashes, not that it's inline instead of extracted.
When the error is thrown (from get-loader-options.js:26), the following values are assigned to the variables:
{
loaderPath:
'/home/wanecek/work/<redacted>/website/node_modules/svg-sprite-loader/lib/loader.js',
rule: {
resource: [Function: bound test],
use: [ { options: undefined, loader: 'file-loader' } ]
},
multiRule: [ { options: undefined, loader: 'file-loader' } ],
multiRuleProp: 'use'
}
rules.map(normalizeRule) evalutes to [{ loader: 'file-loader', options: null }], which makes the chained find method return undefined, causing an error to be thrown when the undefined.options is accessed.
Is it the getMatchedRule which extracts the wrong rule? Not too familiar with the plugin, will try to dig some more...
if the repo given by @evilebottnawi is insufficient, I can try creating a reproducible demo too... Let me know @kisenka :)
So is this problem fixed?
Not that I know of. @kisenka, have you had time to address this? Is there anything we can do to help?
Hey! I'am planning to deprecate and remove extract mode from svg-sprite-loader. To replace it I wrote separate plugin which perform SVG extracting only – extract-svg-sprite-webpack-plugin. Webpack 3 and 4 are supported. It's under heavy development and I suggest you to take part in beta-testing of it. I love my users and want to make them happy!
Most helpful comment
Also stumbled upon this, we replaced extract-text-webpack-plugin with mini-css-extract-plugin and now the svg urls in our css files are replaced by absolute path to the svg file itself instead of url to the svg sprite.
Update: Mine problem sounds more like https://github.com/kisenka/svg-sprite-loader/issues/294 - or maybe its the same thing?