RoccoC / webpack-build-notifier

A Webpack plugin that generates OS notifications for build steps using node-notifier.
MIT License
162 stars 24 forks source link

Is it possible to get notifications for hot reloads? #57

Closed Nantris closed 4 years ago

Nantris commented 4 years ago

It would be great to get notifications of hot reload successes and failures. The motivation for this is that I find that I sometimes require a full reload, but that's not always immediately obvious.

RoccoC commented 4 years ago

Hey @Slapbox , can you elaborate on this a bit? Are you referring to cases when the HMR runtime isn't able to replace a module and generates a warning like [HMR] Cannot apply update. Need to do a full reload! in the browser console?

Since hot reloading takes place in the browser (via the Webpack HMR runtime), and webpack-build-notifier hooks into the node Webpack compilation process on the dev server, there'd need to be a way for the browser to indicate to the server that the hot reload failed -- I'm not sure there is such a mechanism. 🤔

Nantris commented 4 years ago

Hey @RoccoC, thanks for the reply! Yeah that's what I'm referring to. I wish I knew a bit more about the inner workings of Webpack so I could brainstorm possibilities, but for now I'll just have to leave it as a wishlist item.

Does Webpack signal build completion on HMR reloads at all? A success message that the build is done would still be useful for those situation where I'm sure I need a full reload, but need to wait to be sure the build is actually ready.

RoccoC commented 4 years ago

Does Webpack signal build completion on HMR reloads at all?

I'm no expert in Webpack HMR :) but Webpack emits updates that are picked up by the browser HMR runtime when a build is completed successfully. I'm not 100% sure how this works and whether Webpack signals to the browser runtime or if the runtime polls for changes, but I'm guessing the former since it's using a websocket.

A success message that the build is done would still be useful for those situation where I'm sure I need a full reload, but need to wait to be sure the build is actually ready.

By default, webpack-build-notifier should always create a success notification for each build, unless you've set the suppressSuccess config option to something other than false (default). If you aren't seeing any notifications for successful builds (and haven't set the supressSuccess config option), lemme know and I'll take a closer look!

Nantris commented 4 years ago

Thanks again for your speedy reply! I had thought that the success notifications weren't working, but after updating some dependencies, including Webpack itself, it seems to be working properly. Maybe it was always working and I somehow missed it.

With that in mind, I'm going to close this unless you think the hot reload notifications are worth looking into.

Thanks again; your plugin really makes development a lot more pleasant!