Skip to content

Commit e5a2e80

Browse files
authored
docs: adds CLI section in guide (#11025)
1 parent 6c5ecee commit e5a2e80

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

docs/.vitepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ export default defineConfig({
185185
text: 'Features',
186186
link: '/guide/features'
187187
},
188+
{
189+
text: 'CLI',
190+
link: '/guide/cli'
191+
},
188192
{
189193
text: 'Using Plugins',
190194
link: '/guide/using-plugins'

docs/guide/cli.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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 |

docs/guide/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ In a project where Vite is installed, you can use the `vite` binary in your npm
128128

129129
You can specify additional CLI options like `--port` or `--https`. For a full list of CLI options, run `npx vite --help` in your project.
130130

131+
Learn more about the [Command Line Interface](./cli.md)
132+
131133
## Using Unreleased Commits
132134

133135
If you can't wait for a new release to test the latest features, you will need to clone the [vite repo](https://github.com/vitejs/vite) to your local machine and then build and link it yourself ([pnpm](https://pnpm.io/) is required):

0 commit comments

Comments
 (0)