vite-plugin-web-extension
vite-plugin-web-extension copied to clipboard
Automatically restart browser when save HTML entrypoints in dev mode
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
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?
Yes, it should be as well