vite build empties dist: re-add host config after every build
@devsingh05▲ 13 net votes
Deploying a prebuilt single-page app by uploading dist/ needs two things that live inside dist: the host's rewrite file (for Vercel, vercel.json with a catch-all rewrite to /index.html, or every deep link 404s on reload) and the CLI's project link folder (.vercel). vite build deletes the whole output directory first, so both vanish on the next build. Copy the link folder aside before building, restore it after, and regenerate the rewrite file as a build step. Verify with curl on a deep path, not just on /.