Which Cloudflare product(s) does this pertain to?
@cloudflare/vite-plugin
What version(s) of the tool(s) are you using?
@cloudflare/vite-plugin@1.54.0 (also present in the published 1.54.4), vite@8.2.2, wrangler@4.126.0
What version of Node are you using?
24
Describe the Bug
Editing the client's index.html restarts the entire Vite dev server, while Vite simultaneously sends the browser a page reload. The reload lands on a server that is still restarting, so the tab hangs instead of showing the change. A plain vite dev server (plugin removed) does a clean page reload index.html for the same edit.
The cause looks like additional-modules.ts: .html is one of the Text module rules, and the hot-update hook restarts the server for any path in additionalModulePaths:
const moduleRules = [
{ type: "CompiledWasm", pattern: /\.wasm(\?module)?$/ },
{ type: "Data", pattern: /\.bin$/ },
{ type: "Text", pattern: /\.(txt|html|sql)$/ },
];
hotUpdate(options) {
if (additionalModulePaths.has(options.file)) {
options.server.restart();
return [];
}
}
A restart is correct for a .html / .txt / .sql file the Worker imports, since it is baked into the Worker bundle at startup. The client's own HTML entry ends up in the same set, and for it a restart is both unnecessary and actively harmful, because it races Vite's own page reload.
Server log with the plugin enabled, after touch index.html:
@CLOUDFLARE:VITE-PLUGIN 72290: From server.restart(): Restarting server...
[vite] (client) page reload index.html
[vite] server restarted.
Same edit with the plugin removed:
[vite] (client) page reload index.html
A Worker-imported .html (import template from './authorize-page.html?raw') produces the identical restart signature, which is the expected behaviour for that file.
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
Repro on any Worker + SPA app created with the plugin:
vite dev
- Open the app in a browser.
- Edit
index.html (a whitespace change is enough).
- The dev server restarts and the browser's reload hangs until the server is back.
Locally patching the hook to skip the Vite root's index.html fixes it and leaves Worker-imported text modules restarting as before.
Which Cloudflare product(s) does this pertain to?
@cloudflare/vite-pluginWhat version(s) of the tool(s) are you using?
@cloudflare/vite-plugin@1.54.0(also present in the published1.54.4),vite@8.2.2,wrangler@4.126.0What version of Node are you using?
24
Describe the Bug
Editing the client's
index.htmlrestarts the entire Vite dev server, while Vite simultaneously sends the browser apage reload. The reload lands on a server that is still restarting, so the tab hangs instead of showing the change. A plainvitedev server (plugin removed) does a cleanpage reload index.htmlfor the same edit.The cause looks like
additional-modules.ts:.htmlis one of theTextmodule rules, and the hot-update hook restarts the server for any path inadditionalModulePaths:A restart is correct for a
.html/.txt/.sqlfile the Worker imports, since it is baked into the Worker bundle at startup. The client's own HTML entry ends up in the same set, and for it a restart is both unnecessary and actively harmful, because it races Vite's own page reload.Server log with the plugin enabled, after
touch index.html:Same edit with the plugin removed:
A Worker-imported
.html(import template from './authorize-page.html?raw') produces the identical restart signature, which is the expected behaviour for that file.Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
Repro on any Worker + SPA app created with the plugin:
vite devindex.html(a whitespace change is enough).Locally patching the hook to skip the Vite root's
index.htmlfixes it and leaves Worker-imported text modules restarting as before.