cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
207 stars 50 forks source link

Bug: undefined property not caught #143

Closed mlachance closed 3 years ago

mlachance commented 3 years ago

https://github.com/cascornelissen/svg-spritemap-webpack-plugin/blob/82eae12495c34adfcbc11427a295c6271a4fc06b/lib/index.js#L203

This line is throwing the error TypeError: Cannot read property 'warnings' of undefined when I attempt to run Webpack. Manually changing this to :

if ( this.styles.warnings && this.styles.warnings.length ) {

solved the issue in the short term for me.

cascornelissen commented 3 years ago

That makes sense, strange this wasn't caught before... To debug, could you share your configuration? Also, if you want, can you create a PR with that change?

mlachance commented 3 years ago

I'll try to replicate the config (it was an obsolete call to generate sprite SVG's from a nonexistent folder, and I deleted it a few commits ago).

Here was the offending line:

      new SVGSpritemapPlugin(path.resolve(__dirname, "src/sprite/*.svg"), {
        styles: path.resolve(__dirname, "src/scss/_svgsprite.scss"),
      }),

I will make a pull request some time today or tomorrow.

cascornelissen commented 3 years ago

This fix was released in 3.8.3, thanks for your contribution! 🚀