Skip to content

@cloudflare/vite-plugin: editing index.html restarts the dev server and races the page reload #15525

Description

@kunalbhagawati

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:

  1. vite dev
  2. Open the app in a browser.
  3. Edit index.html (a whitespace change is enough).
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package:vite-pluginRelating to the `@cloudflare/vite-plugin` package

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions