Antler by Autoflux

Configuration

Scaffolding a project with create-vite, the vite.config file, aliases, environment files, and the server/build/proxy options that matter.

Path: configuration

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 @/components to src/components; use path.resolve with node:path for absolute paths.
  • serverhost, port, open, proxy (dev-only reverse proxy for /api), and fs.allow (which directories the server may serve — matters in monorepos).
  • buildoutDir, target (baseline browsers), sourcemap, assetsInlineLimit, and rollupOptions.output.manualChunks for hand-tuned chunk splitting.
  • envPrefix — which .env variable names are exposed to client code (default VITE_).
  • publicDir — static files copied verbatim into dist (default public).

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.