Enabling HMR for additional pages ? #116
Replies: 3 comments
-
I created a repro : https://github.com/stevebeauge/repro-vite-browser-ext-no-hmr-in-modal |
Beta Was this translation helpful? Give feedback.
-
HTML files listed under |
Beta Was this translation helpful? Give feedback.
-
So a couple of things I've noticed about the
So you need to change your -const Modal: React.FC = () => {
+export default function() {
return (
<div>
<h1>
Hello from modal!
</h1>
</div>
);
};
-
-export { Modal }; And it works. But that's not a great solution, also not the standard way of writing react, though I am out of date in my react knowledge. I've verified that the regular vite + react + swc template (from |
Beta Was this translation helpful? Give feedback.
-
I'm writing an extension which inject buttons on top of some inputs, in order to inject business data.
The extension is using a content script to extend the page's DOM and opens an overlay whenever the custom button is clicked.
The overlay consists in an IFrame that targets an html file from the extension.
To sum up, I have in my extension:
The button in the content script will create on the fly the iframe element and set its src to the modal.html like this:
In order to have the html page bundled, I updated the vite config like this:
This is working as expected, my modal is properly handled by vite.
However, there's not hot reloading applied within the modal. Everytime I update something, I can see vite's web server recompiling the page, but nothing is updated within the browser (no HMR). I have to manually refresh the extension to see changes.
As far as I understand the source code of this plugin, the observed behavior is normal since this code:
https://github.com/aklinker1/vite-plugin-web-extension/blob/883460dade7892a6d1919edda1956b2efaddc9df/packages/vite-plugin-web-extension/src/build/getViteConfigsForInputs.ts#L101C1-L111
only take the entry points in the HMR process, not the additional files.
Is there anything that can be done ?
Beta Was this translation helpful? Give feedback.
All reactions