cascornelissen / svg-spritemap-webpack-plugin

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

v3.6.0+ is causing mini-css-extract-plugin not to output css file #129

Closed pjho closed 3 years ago

pjho commented 3 years ago

Hey there,

I've had an issue with the upgrade to anything from 3.6.0 and above where my CSS files are no longer being created.

I've setup a lightweight example here https://github.com/pjho/svg-spritemap-webpack-plugin-example.

npm install svg-spritemap-webpack-plugin@3.5.10 && npm run build everything works as expected.

npm install svg-spritemap-webpack-plugin@3.6.0 && npm run build css is not emmitted properly.

Screenshot with 3.5.10

Screen Shot 2020-11-04 at 1 05 08 PM

Screenshot with 3.6.0

Screen Shot 2020-11-04 at 1 05 29 PM

My SvgSpriteMapPlugin config is here https://github.com/pjho/svg-spritemap-webpack-plugin-example/blob/master/webpack.config.js#L34.

Cheers.

pjho commented 3 years ago

Man, looking at the changes you've released between those versions it seems so wierd that they would be the cause of this but switching between those versions definitely effects the output in both my actual setup and the lightweight set up supplied.

Anyways, thanks for an awesome plugin. Any thoughts would be appreciated. :+1:

cascornelissen commented 3 years ago

Interesting, will look at this later today. If you (or anyone else running into this) would like to help figure this out in the meantime:

  1. A PR with a failing test case would help a lot
  2. Knowing what the outcome in both cases is when using Webpack 5 would also help
cascornelissen commented 3 years ago

Alright, seems like it's related to switching from MultiEntryPlugin to SingleEntryPlugin (MultiEntryPlugin isn't available anymore for Webpack 5). I've pushed a change to master, could you test it to ensure it actually fixes your issue:

npm install cascornelissen/svg-spritemap-webpack-plugin#master

Leaving some notes for my future self here in case this ends up being a problem for some reason.

I have absolutely no idea why returning undefined instead of true in the entryOption hook callback resolves this very strange issue but it fixes the issue in the example repo, all tests are passing, and some manual testing didn't result in any problems either.

There's no documentation on the return value of that hook callback, the source code doesn't tell much either. There's not much to be found except for two internal Webpack plugins that hook into entryOption as well (which is what the initial implementation was based on) and they do return true.

pjho commented 3 years ago

Thanks for your comment above. Will check that now. Just been looking into results with Webpack 5.

Knowing what the outcome in both cases is when using Webpack 5 would also help

So with Webpack 5 using the sample repo linked above:

1) no svg-spritemap-webpack-plugin -> builds fine 2) svg-spritemap-webpack-plugin@3.5.10 breaks obviously as it doesn't support WP5. 3) svg-spritemap-webpack-plugin@3.6.0 breaks with the following

Screen Shot 2020-11-05 at 9 36 19 AM

4) svg-spritemap-webpack-plugin@3.7.0 builds fine

Screen Shot 2020-11-05 at 9 37 25 AM
cascornelissen commented 3 years ago

The issue you're seeing with 3.6.0 was fixed in 3.6.1, it's #126 specifically.

It's interesting that scenario 4 works correctly but I guess that's because of some internal changes in SingleEntryPlugin in Webpack 5.

pjho commented 3 years ago

Cool just tested cascornelissen/svg-spritemap-webpack-plugin#master in both sample repo and my full repo with webpcak 4 and all is building fine 🎉

Thanks for looking into it so quickly and for maintaining this plugin :+1:

cascornelissen commented 3 years ago

No problem at all, thanks for reporting the issue. The fix was released with version 3.7.1 which I have just published on NPM 🚀

Let's hope there's not another issue reported here later this week that would be caused by this 🤞🏼