Restart Vite Dev Server When Required
When to apply
- •The user says the frontend or Vite needs a restart, or something "doesn't work until you restart the dev server".
- •You made changes that require a Vite restart (e.g.
vite.config.ts,.envor env vars, proxy settings, or other config read at dev server startup). - •You previously said "restart the Vite dev server" or "restart the frontend" and want to do it yourself from now on.
What to do
- •
If the project has a restart script (e.g.
restart-frontend.shin the repo root):- •Run it from the project root:
./restart-frontend.sh - •Use the terminal. The script typically stops the current Vite dev server (e.g. port 5173) and starts it again (foreground or background per project).
- •Do not tell the user to restart the frontend manually.
- •Run it from the project root:
- •
If there is no restart script but there is a run script (e.g.
run-frontend.sh):- •Stop any process on the Vite port (e.g. 5173:
lsof -ti:5173 | xargs kill) orpkill -f "vite", then run the run script. Prefer adding arestart-frontend.shthat stops and then calls the run script, then run it.
- •Stop any process on the Vite port (e.g. 5173:
Important
- •Do not say "restart the Vite dev server" or "you need to restart the frontend" without actually running the restart when you have the ability to run the script.
- •Run the restart script from the project root so the script path is correct.