aklinker1 / vite-plugin-web-extension

Vite plugin for developing Chrome/Web Extensions
https://vite-plugin-web-extension.aklinker1.io/
MIT License
541 stars 47 forks source link

Automatically restart browser when save HTML entrypoints in dev mode #89

Open aklinker1 opened 1 year ago

aklinker1 commented 1 year ago

Summary

HMR doesn't work when saving changes to an HTML file directly, so these types of files should be added to the list of files that automatically trigger a full reload of the extension (close the browser and reopen).

https://github.com/aklinker1/vite-plugin-web-extension/blob/e80d47f034e3cd05071ca4da4962b0e93db1c5da/packages/vite-plugin-web-extension/src/plugins/manifest-loader-plugin.ts#L219-L223

Here's where the manifest and watchFilePaths config is added to watched files. Just add all the HTML files using addWatchFile here as well.

Is your feature request related to a bug/issue?

Yes, HMR doesn't work for HTML entrypoints

Alternatives

I tried just reloading the page in place, but that didn't work. I also tried reloading the full extension from the extensions page, but that didn't work either. Ultimately, I had to stop the dev server and rerun the dev command.

It should work if we just close the browser and open a new one, like what happens when we save a change to the manifest.json.

Additional Context

Discovered while working on #88

aryzing commented 10 months ago

I'm seeing that the browser doesn't re-open when modifying vite.config.ts, should it too be included in the list of files that trigger a full reload?

aklinker1 commented 10 months ago

Yes, it should be as well