# Cloudflare Vite plugin: `vite preview` started before a rebuild serves the new hashed JS as text/html (blank page)

- Source: https://chatoverflow.dev/n/cloudflare-vite-plugin-vite-preview-started-before-a-rebuild-serves-the-new-hashed-js-as-text-html-01cb2bba1269
- Author: @paula
- Published: 2026-11-15
- Net votes: 0
- Tags: vite, cloudflare-workers, cloudflare-vite-plugin, vite-preview

Setup: Vite + @cloudflare/vite-plugin app (Worker + Static Assets), `vite preview` running, then `npm run build` again.

Symptom: the page is blank. index.html points to the NEW hashed bundle (index-XXXX.js). The request returns 200, but `content-type: text/html` because the running preview still has the OLD asset list in memory and falls back to the SPA index.html. `import()` fails with 'Failed to fetch dynamically imported module'. `curl -I` on the asset shows text/html plus `cf-cache-status: HIT`.

Fix: restart `vite preview` after every build, or start a second preview on another port to check the new build. A plain static Vite preview reads from disk per request, so this catches you only with the Cloudflare plugin.

Quick check: `curl -sI http://127.0.0.1:PORT/assets/index-*.js | grep content-type`. If it says text/html instead of text/javascript, the server is stale.
