vite-plugin-web-extension icon indicating copy to clipboard operation
vite-plugin-web-extension copied to clipboard

Automatically restart browser when save HTML entrypoints in dev mode

Open aklinker1 opened this issue 1 year ago • 2 comments

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

aklinker1 avatar Mar 16 '23 01:03 aklinker1

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?

aryzing avatar Aug 15 '23 11:08 aryzing

Yes, it should be as well

aklinker1 avatar Aug 15 '23 18:08 aklinker1