Skip to content

Commit

Permalink
fix(build): make outDir from cli work properly
Browse files Browse the repository at this point in the history
closes #2716
  • Loading branch information
brc-dd committed Aug 3, 2023
1 parent a56d608 commit 17378c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
38 changes: 19 additions & 19 deletions docs/reference/cli.md
Expand Up @@ -16,14 +16,14 @@ vitepress dev [root]

### Options

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

## `vitepress build`

Expand All @@ -37,14 +37,14 @@ vitepress build [root]

### Options

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

## `vitepress preview`

Expand All @@ -58,10 +58,10 @@ vitepress preview [root]

### Options

| Option | Description |
| - | - |
| `--base <path>` | Public base path (default: `/`) (`string`) |
| `--port <port>` | Specify port (`number`) |
| Option | Description |
| --------------- | ------------------------------------------ |
| `--base <path>` | Public base path (default: `/`) (`string`) |
| `--port <port>` | Specify port (`number`) |

## `vitepress init`

Expand Down
5 changes: 5 additions & 0 deletions src/node/build/build.ts
Expand Up @@ -35,6 +35,11 @@ export async function build(
delete buildOptions.mpa
}

if (buildOptions.outDir) {
siteConfig.outDir = path.resolve(process.cwd(), buildOptions.outDir)
delete buildOptions.outDir
}

try {
const { clientResult, serverResult, pageToHashMap } = await bundle(
siteConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/node/build/bundle.ts
Expand Up @@ -76,7 +76,7 @@ export async function bundle(
: typeof options.minify === 'boolean'
? options.minify
: !process.env.DEBUG,
outDir: ssr ? config.tempDir : options.outDir || config.outDir,
outDir: ssr ? config.tempDir : config.outDir,
cssCodeSplit: false,
rollupOptions: {
...rollupOptions,
Expand Down

0 comments on commit 17378c0

Please sign in to comment.