Configuration
Scaffolding a project with create-vite, the vite.config file, aliases, environment files, and the server/build/proxy options that matter.
Third-party documentation. This is independently authored analysis of the public Vite codebase — not the official docs, and not reviewed or endorsed by the Vite team.
Configuration
Vite is configured through vite.config.ts (or .js/.mjs), evaluated with Node. Wrapping the object in defineConfig gives you TypeScript autocompletion and validation of every key. The config is the single source of truth for both the dev server and the production build.
Scaffolding
npm create vite@latest (create-vite) generates a project from an official template: -- --template react-ts, vue-ts, svelte-ts, solid-ts, preact-ts, lit-ts, vanilla-ts, and the JS-only variants. Templates include the framework plugin, an index.html entry, and sensible defaults; you add configuration as your project grows.
Common options
plugins— framework and custom plugins, applied in order.resolve.alias— map deep imports like@/componentstosrc/components; usepath.resolvewithnode:pathfor absolute paths.server—host,port,open,proxy(dev-only reverse proxy for/api), andfs.allow(which directories the server may serve — matters in monorepos).build—outDir,target(baseline browsers),sourcemap,assetsInlineLimit, androllupOptions.output.manualChunksfor hand-tuned chunk splitting.envPrefix— which.envvariable names are exposed to client code (defaultVITE_).publicDir— static files copied verbatim intodist(defaultpublic).
Environment files
.env, .env.local, .env.[mode], and .env.[mode].local are loaded in order of specificity; only VITE_-prefixed keys are exposed via import.meta.env. The --mode CLI flag (or NODE_ENV) selects the mode — development by default for vite dev, production for vite build.
