Vite does not revalidate inline scripts on page reloads #18685
-
👋 I am creating a simple plugin which transforms HTML and that HTML is expected to have simple P.S.: if I make a change in the HTML file, the next block of code makes sure the JS file is invalidated, so the latest content is pushed to the browser. handleHotUpdate({ server }) {
server.ws.send({ type: "full-reload" });
server.moduleGraph.invalidateAll();
return [];
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Adding the configureServer(server) {
return () => {
server.middlewares.use((req, res, next) => {
// ...
server.moduleGraph.invalidateAll();
// ...
next();
});
};
} |
Beta Was this translation helpful? Give feedback.
-
Would it help if you add |
Beta Was this translation helpful? Give feedback.
Thanks for the concise repro. From a quick look, this could be a bug. I see plugin's
transformIndexHtml
hook is called for each html request but corresponding js proxy module isn't always invalidated (though it looks like they are invalidated after editing html?).Probably it's worth raising an issue if you don't see one already.
EDIT: maybe this will fix it #18696