# Command Line Interface ## Dev server ### `vite` Start Vite dev server in the current directory. `vite dev` and `vite serve` are aliases for `vite`. #### Usage ```bash vite [root] ``` #### Options | Options | | | ------------------------ | ------------------------------------------------------------------------------------------------------------------ | | `--host [host]` | Specify hostname (`string`) | | `--port ` | Specify port (`number`) | | `--open [path]` | Open browser on startup (`boolean \| string`) | | `--cors` | Enable CORS (`boolean`) | | `--strictPort` | Exit if specified port is already in use (`boolean`) | | `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | | `-c, --config ` | Use specified config file (`string`) | | `--base ` | Public base path (default: `/`) (`string`) | | `-l, --logLevel ` | info \| warn \| error \| silent (`string`) | | `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | | `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) | | `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | | `-f, --filter ` | Filter debug logs (`string`) | | `-m, --mode ` | Set env mode (`string`) | | `-h, --help` | Display available CLI options | | `-v, --version` | Display version number | ## Build ### `vite build` Build for production. #### Usage ```bash vite build [root] ``` #### Options | Options | | | ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | | `--target ` | Transpile target (default: `"modules"`) (`string`) | | `--outDir ` | Output directory (default: `dist`) (`string`) | | `--assetsDir ` | Directory under outDir to place assets in (default: `"assets"`) (`string`) | | `--assetsInlineLimit ` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) | | `--ssr [entry]` | Build specified entry for server-side rendering (`string`) | | `--sourcemap [output]` | Output source maps for build (default: `false`) (`boolean \| "inline" \| "hidden"`) | | `--minify [minifier]` | Enable/disable minification, or specify minifier to use (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) | | `--manifest [name]` | Emit build manifest json (`boolean \| string`) | | `--ssrManifest [name]` | Emit ssr manifest json (`boolean \| string`) | | `--emptyOutDir` | Force empty outDir when it's outside of root (`boolean`) | | `-w, --watch` | Rebuilds when modules have changed on disk (`boolean`) | | `-c, --config ` | Use specified config file (`string`) | | `--base ` | Public base path (default: `/`) (`string`) | | `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | | `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | | `--profile` | Start built-in Node.js inspector (check [Performance bottlenecks](/guide/troubleshooting#performance-bottlenecks)) | | `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | | `-f, --filter ` | Filter debug logs (`string`) | | `-m, --mode ` | Set env mode (`string`) | | `-h, --help` | Display available CLI options | | `--app` | Build all environments, same as `builder: {}` (`boolean`, experimental) | ## Others ### `vite optimize` Pre-bundle dependencies. #### Usage ```bash vite optimize [root] ``` #### Options | Options | | | ------------------------ | ----------------------------------------------------------------- | | `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | | `-c, --config ` | Use specified config file (`string`) | | `--base ` | Public base path (default: `/`) (`string`) | | `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | | `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | | `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | | `-f, --filter ` | Filter debug logs (`string`) | | `-m, --mode ` | Set env mode (`string`) | | `-h, --help` | Display available CLI options | ### `vite preview` Locally preview the production build. Do not use this as a production server as it's not designed for it. #### Usage ```bash vite preview [root] ``` #### Options | Options | | | ------------------------ | ---------------------------------------------------- | | `--host [host]` | Specify hostname (`string`) | | `--port ` | Specify port (`number`) | | `--strictPort` | Exit if specified port is already in use (`boolean`) | | `--open [path]` | Open browser on startup (`boolean \| string`) | | `--outDir ` | Output directory (default: `dist`)(`string`) | | `-c, --config ` | Use specified config file (`string`) | | `--base ` | Public base path (default: `/`) (`string`) | | `-l, --logLevel ` | Info \| warn \| error \| silent (`string`) | | `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | | `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | | `-f, --filter ` | Filter debug logs (`string`) | | `-m, --mode ` | Set env mode (`string`) | | `-h, --help` | Display available CLI options |