soda-x/extra-watch-webpack-plugin

Only works if not alone in plugins list

Opened this issue · 5 comments

I made a dummy project, to get the simplest situation where the problem occurs:

ExtraWatchWebpackPlugin_bug.zip

If you run npm run build, it will watch index.js, as it is the entry point, but it will not watch extra.js.

However, if you uncomment the webpack.BannerPlugin plugin in webpack.config.js, now it successfully watch extra.js.

I can't explain this behavior. I added some console logs in ExtraWatchWebpackPlugin, and it seems like it always reacts when extra.js is modified, but the output file is not rebuilt.

Any help appreciated!

In fact, it doesn't work in either situation.

But it works well by using webpack-dev-server to debug this demo.

I debugged ExtraWatchWebpackPlugin it seems everything is ok, I'm not sure where the issue comes from right now. An additional parameter may be required when you using webpack-cli watch mode directly.

I'm so sorry for this issue, I need some time to do more debugging.

Hey @pigcan, thank you for the quick reply!
I am not sure it comes from your package, because the very same problem occurs with webpack-watch-files-plugin (your "competitor").
How did you use webpack-dev-server exactly? I tried adding it on top of extra-watch-webpack-plugin but it doesnt seem to do anything either.

package.json

{
  "scripts": {
    "start": "webpack-dev-server"
  },
  "dependencies": {
    "webpack-dev-server": "*"
  }
}

I see, I am not familiar with webpack-dev-server, and didn't realize I had to call it instead of classic npx webpack.
Yeah it definitely works fine with it.
Is it possible that your plugin relies on a feature that is provided/expoited by other plugins as well as webpack-dev-server, but not from/by vanilla webpack?

The plugin relies on webpack definitely.

https://github.com/pigcan/extra-watch-webpack-plugin/blob/master/src/index.js#L63
https://github.com/pigcan/extra-watch-webpack-plugin/blob/master/src/index.js#L68

But I am not sure why it can't be worked. Later I will work on it.