2022-11-25 16:41:05 +01:00
# Command Line Interface
## Dev server
### `vite`
2024-03-12 14:52:05 +09:00
Start Vite dev server in the current directory. `vite dev` and `vite serve` are aliases for `vite` .
2022-11-25 16:41:05 +01:00
#### Usage
``` bash
vite [ root]
```
#### Options
2025-12-02 15:19:45 +09:00
| Options | |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--host [host]` | Specify hostname (`string` ) |
| `--port <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 <file>` | Use specified config file (`string` ) |
| `--base <path>` | Public base path (default: `/` ) (`string` ) |
| `-l, --logLevel <level>` | info \| warn \| error \| silent (`string` ) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean` ) |
| `--configLoader <loader>` | Use `bundle` to bundle the config with Rolldown, or `runner` (experimental) to process it on the fly, or `native` (experimental) to load using the native runtime (default: `bundle` ) |
| `--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>` | Filter debug logs (`string` ) |
| `-m, --mode <mode>` | Set env mode (`string` ) |
| `-h, --help` | Display available CLI options |
| `-v, --version` | Display version number |
2022-11-25 16:41:05 +01:00
## Build
### `vite build`
Build for production.
#### Usage
``` bash
vite build [ root]
```
#### Options
2025-12-02 15:19:45 +09:00
| Options | |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `--target <target>` | Transpile target (default: `"modules"` ) (`string` ) |
| `--outDir <dir>` | Output directory (default: `dist` ) (`string` ) |
| `--assetsDir <dir>` | Directory under outDir to place assets in (default: `"assets"` ) (`string` ) |
| `--assetsInlineLimit <number>` | 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 <file>` | Use specified config file (`string` ) |
| `--base <path>` | Public base path (default: `/` ) (`string` ) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string` ) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean` ) |
| `--configLoader <loader>` | Use `bundle` to bundle the config with Rolldown or `runner` (experimental) to process it on the fly (default: `bundle` ) |
| `--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>` | Filter debug logs (`string` ) |
| `-m, --mode <mode>` | Set env mode (`string` ) |
| `-h, --help` | Display available CLI options |
| `--app` | Build all environments, same as `builder: {}` (`boolean` , experimental) |
2022-11-25 16:41:05 +01:00
## Others
### `vite optimize`
Pre-bundle dependencies.
2025-02-05 20:17:06 +09:00
**Deprecated ** : the pre-bundle process runs automatically and does not need to be called.
2022-11-25 16:41:05 +01:00
#### Usage
``` bash
vite optimize [ root]
```
#### Options
2025-12-02 15:19:45 +09:00
| Options | |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean` ) |
| `-c, --config <file>` | Use specified config file (`string` ) |
| `--base <path>` | Public base path (default: `/` ) (`string` ) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string` ) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean` ) |
| `--configLoader <loader>` | Use `bundle` to bundle the config with Rolldown or `runner` (experimental) to process it on the fly (default: `bundle` ) |
| `-d, --debug [feat]` | Show debug logs (`string \| boolean` ) |
| `-f, --filter <filter>` | Filter debug logs (`string` ) |
| `-m, --mode <mode>` | Set env mode (`string` ) |
| `-h, --help` | Display available CLI options |
2022-11-25 16:41:05 +01:00
### `vite preview`
2023-05-24 09:21:38 +02:00
Locally preview the production build. Do not use this as a production server as it's not designed for it.
2022-11-25 16:41:05 +01:00
2025-10-06 04:52:53 +01:00
This command starts a server in the build directory (by default `dist` ). Run `vite build` beforehand to ensure that the build directory is up-to-date. Depending on the project's configured [`appType` ](/config/shared-options.html#apptype ), it makes use of certain middleware.
2022-11-25 16:41:05 +01:00
#### Usage
``` bash
vite preview [ root]
```
#### Options
2025-12-02 15:19:45 +09:00
| Options | |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `--host [host]` | Specify hostname (`string` ) |
| `--port <port>` | Specify port (`number` ) |
| `--strictPort` | Exit if specified port is already in use (`boolean` ) |
| `--open [path]` | Open browser on startup (`boolean \| string` ) |
| `--outDir <dir>` | Output directory (default: `dist` )(`string` ) |
| `-c, --config <file>` | Use specified config file (`string` ) |
| `--base <path>` | Public base path (default: `/` ) (`string` ) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string` ) |
| `--clearScreen` | Allow/disable clear screen when logging (`boolean` ) |
| `--configLoader <loader>` | Use `bundle` to bundle the config with Rolldown or `runner` (experimental) to process it on the fly (default: `bundle` ) |
| `-d, --debug [feat]` | Show debug logs (`string \| boolean` ) |
| `-f, --filter <filter>` | Filter debug logs (`string` ) |
| `-m, --mode <mode>` | Set env mode (`string` ) |
| `-h, --help` | Display available CLI options |