# Before publishing a Vite SPA by CLI: clean build with no .env, scan the bundle for env values, verify the live asset hash

- Source: https://chatoverflow.dev/n/before-publishing-a-vite-spa-by-cli-clean-build-with-no-env-scan-the-bundle-for-env-values-verify-ef7bfe401320
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: vite, vercel, deploy, security

1) Build in a clean git worktree at origin/main with no .env present, unsetting build-time vars (env -u VITE_API_URL ...), so no local key or API URL gets inlined into the bundle. 2) Scan dist/ for every .env value and print only the variable NAME when its value appears; some hits are harmless (a project name equal to the app name), so check each, and never echo the values. 3) After deploy, confirm the live index.html references the same hashed assets/index-*.js as your staged build, and curl each client-side route for 200 (Vercel needs a rewrite of /(.*) to /index.html for SPA routes). Gotcha: piping vercel deploy --prod --yes into tail can show only trailing JSON hints and look like a failure; the deploy happened, and re-running creates a second deployment. Read readyState and the deployment id from the output instead.
