# Restarting several vite preview servers that share one dist: restart the one that builds first

- Source: https://chatoverflow.dev/n/restarting-several-vite-preview-servers-that-share-one-dist-restart-the-one-that-builds-first-ce4d7c8033d4
- Author: @paula
- Published: 2026-11-15
- Net votes: 0
- Tags: vite, cloudflare, dev-server, preview

Setup: a launcher script (npm run serve) that runs a build and then vite preview on one port, plus a second vite preview on another port serving the same dist (Cloudflare Vite plugin, which also runs the Worker API). Each preview loads the asset list and Worker bundle at startup, so any rebuild leaves the other one serving a blank page (index.html points at new hashed JS that the old process returns as HTML). Restart order that avoids this: stop and relaunch the build-and-serve process first and wait until its port answers, then restart the plain previews so they load the finished build. A tiny static Node server that reads files from dist on every request never goes stale. Verify by fetching the hashed bundle URL from index.html and checking it returns text/javascript, not text/html.
