|
| 1 | +# Command Line Interface |
| 2 | + |
| 3 | +## Dev server |
| 4 | + |
| 5 | +### `vite` |
| 6 | + |
| 7 | +Start Vite dev server in the current directory. Will enter the watch mode in development environment and run mode in CI automatically. |
| 8 | + |
| 9 | +#### Usage |
| 10 | + |
| 11 | +```bash |
| 12 | +vite [root] |
| 13 | +``` |
| 14 | + |
| 15 | +#### Options |
| 16 | + |
| 17 | +| Options | | |
| 18 | +| ------------------------ | ----------------------------------------------------------------- | |
| 19 | +| `--host [host]` | Specify hostname (`string`) | |
| 20 | +| `--port <port>` | Specify port (`number`) | |
| 21 | +| `--https` | Use TLS + HTTP/2 (`boolean`) | |
| 22 | +| `--open [path]` | Open browser on startup (`boolean \| string`) | |
| 23 | +| `--cors` | Enable CORS (`boolean`) | |
| 24 | +| `--strictPort` | Exit if specified port is already in use (`boolean`) | |
| 25 | +| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | |
| 26 | +| `-c, --config <file>` | Use specified config file (`string`) | |
| 27 | +| `--base <path>` | Public base path (default: `/`) (`string`) | |
| 28 | +| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) | |
| 29 | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | |
| 30 | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | |
| 31 | +| `-f, --filter <filter>` | Filter debug logs (`string`) | |
| 32 | +| `-m, --mode <mode>` | Set env mode (`string`) | |
| 33 | +| `-h, --help` | Display available CLI options | |
| 34 | +| `-v, --version` | Display version number | |
| 35 | + |
| 36 | +## Build |
| 37 | + |
| 38 | +### `vite build` |
| 39 | + |
| 40 | +Build for production. |
| 41 | + |
| 42 | +#### Usage |
| 43 | + |
| 44 | +```bash |
| 45 | +vite build [root] |
| 46 | +``` |
| 47 | + |
| 48 | +#### Options |
| 49 | + |
| 50 | +| Options | | |
| 51 | +| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | |
| 52 | +| `--target <target>` | Transpile target (default: `"modules"`) (`string`) | |
| 53 | +| `--outDir <dir>` | Output directory (default: `dist`) (`string`) | |
| 54 | +| `--assetsDir <dir>` | Directory under outDir to place assets in (default: `"assets"`) (`string`) | |
| 55 | +| `--assetsInlineLimit <number>` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) | |
| 56 | +| `--ssr [entry]` | Build specified entry for server-side rendering (`string`) | |
| 57 | +| `--sourcemap` | Output source maps for build (default: `false`) (`boolean`) | |
| 58 | +| `--minify [minifier]` | Enable/disable minification, or specify minifier to use (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) | |
| 59 | +| `--manifest [name]` | Emit build manifest json (`boolean \| string`) | |
| 60 | +| `--ssrManifest [name]` | Emit ssr manifest json (`boolean \| string`) | |
| 61 | +| `--force` | Force the optimizer to ignore the cache and re-bundle (experimental)(`boolean`) | |
| 62 | +| `--emptyOutDir` | Force empty outDir when it's outside of root (`boolean`) | |
| 63 | +| `-w, --watch` | Rebuilds when modules have changed on disk (`boolean`) | |
| 64 | +| `-c, --config <file>` | Use specified config file (`string`) | |
| 65 | +| `--base <path>` | Public base path (default: `/`) (`string`) | |
| 66 | +| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) | |
| 67 | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | |
| 68 | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | |
| 69 | +| `-f, --filter <filter>` | Filter debug logs (`string`) | |
| 70 | +| `-m, --mode <mode>` | Set env mode (`string`) | |
| 71 | +| `-h, --help` | Display available CLI options | |
| 72 | + |
| 73 | +## Others |
| 74 | + |
| 75 | +### `vite optimize` |
| 76 | + |
| 77 | +Pre-bundle dependencies. |
| 78 | + |
| 79 | +#### Usage |
| 80 | + |
| 81 | +```bash |
| 82 | +vite optimize [root] |
| 83 | +``` |
| 84 | + |
| 85 | +#### Options |
| 86 | + |
| 87 | +| Options | | |
| 88 | +| ------------------------ | ----------------------------------------------------------------- | |
| 89 | +| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) | |
| 90 | +| `-c, --config <file>` | Use specified config file (`string`) | |
| 91 | +| `--base <path>` | Public base path (default: `/`) (`string`) | |
| 92 | +| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) | |
| 93 | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | |
| 94 | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | |
| 95 | +| `-f, --filter <filter>` | Filter debug logs (`string`) | |
| 96 | +| `-m, --mode <mode>` | Set env mode (`string`) | |
| 97 | +| `-h, --help` | Display available CLI options | |
| 98 | + |
| 99 | +### `vite preview` |
| 100 | + |
| 101 | +Locally preview production build. |
| 102 | + |
| 103 | +#### Usage |
| 104 | + |
| 105 | +```bash |
| 106 | +vite preview [root] |
| 107 | +``` |
| 108 | + |
| 109 | +#### Options |
| 110 | + |
| 111 | +| Options | | |
| 112 | +| ------------------------ | ---------------------------------------------------- | |
| 113 | +| `--host [host]` | Specify hostname (`string`) | |
| 114 | +| `--port <port>` | Specify port (`number`) | |
| 115 | +| `--strictPort` | Exit if specified port is already in use (`boolean`) | |
| 116 | +| `--https` | Use TLS + HTTP/2 (`boolean`) | |
| 117 | +| `--open [path]` | Open browser on startup (`boolean \| string`) | |
| 118 | +| `--outDir <dir>` | Output directory (default: `dist`)(`string`) | |
| 119 | +| `-c, --config <file>` | Use specified config file (`string`) | |
| 120 | +| `--base <path>` | Public base path (default: `/`) (`string`) | |
| 121 | +| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) | |
| 122 | +| `--clearScreen` | Allow/disable clear screen when logging (`boolean`) | |
| 123 | +| `-d, --debug [feat]` | Show debug logs (`string \| boolean`) | |
| 124 | +| `-f, --filter <filter>` | Filter debug logs (`string`) | |
| 125 | +| `-m, --mode <mode>` | Set env mode (`string`) | |
| 126 | +| `-h, --help` | Display available CLI options | |
0 commit comments