Dev server
vite
Start the dev server (aliases: dev, serve)
vite <root>
Serve a different project root
The config file must live in that root.
vite --port <port>
Set the port (default 5173)
vite --strictPort
Fail instead of picking another port
vite --host [host]
Listen on all addresses or a given host
On WSL2 --host alone may not be enough for LAN access.
vite --open [path]
Open the browser on start
vite --force
Ignore the optimizer cache
vite --mode <mode>
Set the env mode (default development)
vite --base <path>
Set the public base path
vite --config <file>
Use a specific config file
Build
vite build
Production build into dist/
vite build --outDir <dir>
Change the output directory
vite build --sourcemap [output]
Emit source maps (true, inline, hidden)
vite build --mode <mode>
Build with another env mode
Mode and NODE_ENV are separate: build keeps
NODE_ENV=production.
vite build --watch
Rebuild when files change
vite build --minify <minifier>
Pick minifier: oxc, terser, esbuild, false
vite build --target <target>
Set the transpile target
vite build --base <path>
Build for a sub-path deployment
vite build --emptyOutDir
Empty outDir even outside the root
vite build --manifest [name]
Emit a manifest of hashed assets
vite build --ssr [entry]
Build an entry for server rendering
Preview
vite preview
Serve the built dist/ locally
vite preview --port <port>
Set the preview port
vite preview --host [host]
Expose the preview on the network
vite preview --open [path]
Open the browser on start
vite preview --outDir <dir>
Serve a non-default build folder
vite optimize
Pre-bundle dependencies (deprecated)
Deprecated: this already runs automatically.
Scaffolding
npm create vite@latest <name>
Create a project interactively
npm create vite@latest <name> -- --template
<tpl>
Scaffold a template (npm 7+ needs --)
pnpm create vite <name> --template <tpl>
Same with pnpm (no extra --)
npm create vite@latest . -- --template <tpl>
Scaffold in the current directory
npm create vite@latest <name> --
--no-interactive
Scaffold without prompts
Template names
| Framework |
Plain JS |
TypeScript |
vanilla |
vanilla |
vanilla-ts |
vue |
vue |
vue-ts |
react |
react |
react-ts |
react (compiler) |
react-compiler |
react-compiler-ts |
preact |
preact |
preact-ts |
svelte |
svelte |
svelte-ts |
solid |
solid |
solid-ts |
lit |
lit |
lit-ts |
qwik |
qwik |
qwik-ts |