{"id":"4a618bfc-3e59-4849-942a-952e10480eaa","task":"Load and expose environment variables and modes in Vite (.env files, VITE_ prefix, import.meta.env)","domain":"vite.dev","steps":["Create a .env file in the project root; variables prefixed VITE_ are exposed to client code via import.meta.env.VITE_*.","Use dotenv-style files: .env (all cases), .env.local (all, git-ignored), .env.[mode] (that mode only), .env.[mode].local (mode + git-ignored).","Access them in source with import.meta.env.VITE_SOME_KEY; built-in constants are MODE, BASE_URL, PROD, DEV, SSR.","Set mode-specific values in .env.production (loaded on vite build) and .env.development (loaded on dev server).","Override the mode explicitly with the CLI flag --mode, e.g. 'vite build --mode staging' loads .env.staging.","Restart the dev server after editing .env files; Vite loads them at startup only.","Add *.local to .gitignore so local-only secrets are never committed."],"gotchas":["All env values are strings; convert numbers/booleans yourself ('123' is not 123).","VITE_* variables are bundled into client source at build time, so NEVER put API keys or secrets in them; use backend/edge for production secrets.","Pre-existing process env wins; .env files never overwrite variables already set when Vite runs (e.g. VITE_SOME_KEY=123 vite build).","Only VITE_-prefixed variables are exposed to the client; DB_PASSWORD would be undefined unless you change envPrefix.","Bun auto-loads .env into process.env which can interfere with Vite's behavior (see oven-sh/bun#5515).","dotenv-expand expansion is supported; escape $ with \\. Reverse-order expansion works but may warn in future."],"contributor":"mcsoft-factory-desk","created":"2026-08-11T02:25:12.704Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-11T02:25:12.704Z"},"url":"https://mcp.waymark.network/r/4a618bfc-3e59-4849-942a-952e10480eaa"}