Skip to content

Commit 17378c0

Browse files
committedAug 3, 2023
fix(build): make outDir from cli work properly
closes #2716
1 parent a56d608 commit 17378c0

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed
 

‎docs/reference/cli.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ vitepress dev [root]
1616

1717
### Options
1818

19-
| Option | Description |
20-
| - | - |
21-
| `--open [path]` | Open browser on startup (`boolean \| string`) |
22-
| `--port <port>` | Specify port (`number`) |
23-
| `--base <path>` | Public base path (default: `/`) (`string`) |
24-
| `--cors` | Enable CORS |
25-
| `--strictPort` | Exit if specified port is already in use (`boolean`) |
26-
| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) |
19+
| Option | Description |
20+
| --------------- | ----------------------------------------------------------------- |
21+
| `--open [path]` | Open browser on startup (`boolean \| string`) |
22+
| `--port <port>` | Specify port (`number`) |
23+
| `--base <path>` | Public base path (default: `/`) (`string`) |
24+
| `--cors` | Enable CORS |
25+
| `--strictPort` | Exit if specified port is already in use (`boolean`) |
26+
| `--force` | Force the optimizer to ignore the cache and re-bundle (`boolean`) |
2727

2828
## `vitepress build`
2929

@@ -37,14 +37,14 @@ vitepress build [root]
3737

3838
### Options
3939

40-
| Option | Description |
41-
| - | - |
42-
| `--mpa` (experimental) | Build in [MPA mode](../guide/mpa-mode) without client-side hydration (`boolean`) |
43-
| `--base <path>` | Public base path (default: `/`) (`string`) |
44-
| `--target <target>` | Transpile target (default: `"modules"`) (`string`) |
45-
| `--outDir <dir>` | Output directory (default: `.vitepress/dist`) (`string`) |
40+
| Option | Description |
41+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
42+
| `--mpa` (experimental) | Build in [MPA mode](../guide/mpa-mode) without client-side hydration (`boolean`) |
43+
| `--base <path>` | Public base path (default: `/`) (`string`) |
44+
| `--target <target>` | Transpile target (default: `"modules"`) (`string`) |
45+
| `--outDir <dir>` | Output directory relative to **cwd** (default: `<root>/.vitepress/dist`) (`string`) |
4646
| `--minify [minifier]` | Enable/disable minification, or specify minifier to use (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
47-
| `--assetsInlineLimit <number>` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) |
47+
| `--assetsInlineLimit <number>` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) |
4848

4949
## `vitepress preview`
5050

@@ -58,10 +58,10 @@ vitepress preview [root]
5858

5959
### Options
6060

61-
| Option | Description |
62-
| - | - |
63-
| `--base <path>` | Public base path (default: `/`) (`string`) |
64-
| `--port <port>` | Specify port (`number`) |
61+
| Option | Description |
62+
| --------------- | ------------------------------------------ |
63+
| `--base <path>` | Public base path (default: `/`) (`string`) |
64+
| `--port <port>` | Specify port (`number`) |
6565

6666
## `vitepress init`
6767

‎src/node/build/build.ts

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export async function build(
3535
delete buildOptions.mpa
3636
}
3737

38+
if (buildOptions.outDir) {
39+
siteConfig.outDir = path.resolve(process.cwd(), buildOptions.outDir)
40+
delete buildOptions.outDir
41+
}
42+
3843
try {
3944
const { clientResult, serverResult, pageToHashMap } = await bundle(
4045
siteConfig,

‎src/node/build/bundle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function bundle(
7676
: typeof options.minify === 'boolean'
7777
? options.minify
7878
: !process.env.DEBUG,
79-
outDir: ssr ? config.tempDir : options.outDir || config.outDir,
79+
outDir: ssr ? config.tempDir : config.outDir,
8080
cssCodeSplit: false,
8181
rollupOptions: {
8282
...rollupOptions,

0 commit comments

Comments
 (0)
Please sign in to comment.