fix(build): make outDir from cli work properly

closes #2716
pull/2723/head
Divyansh Singh 1 year ago
parent a56d608bec
commit 17378c064f

@ -17,7 +17,7 @@ vitepress dev [root]
### Options ### Options
| Option | Description | | Option | Description |
| - | - | | --------------- | ----------------------------------------------------------------- |
| `--open [path]` | Open browser on startup (`boolean \| string`) | | `--open [path]` | Open browser on startup (`boolean \| string`) |
| `--port <port>` | Specify port (`number`) | | `--port <port>` | Specify port (`number`) |
| `--base <path>` | Public base path (default: `/`) (`string`) | | `--base <path>` | Public base path (default: `/`) (`string`) |
@ -38,11 +38,11 @@ vitepress build [root]
### Options ### Options
| Option | Description | | Option | Description |
| - | - | | ------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
| `--mpa` (experimental) | Build in [MPA mode](../guide/mpa-mode) without client-side hydration (`boolean`) | | `--mpa` (experimental) | Build in [MPA mode](../guide/mpa-mode) without client-side hydration (`boolean`) |
| `--base <path>` | Public base path (default: `/`) (`string`) | | `--base <path>` | Public base path (default: `/`) (`string`) |
| `--target <target>` | Transpile target (default: `"modules"`) (`string`) | | `--target <target>` | Transpile target (default: `"modules"`) (`string`) |
| `--outDir <dir>` | Output directory (default: `.vitepress/dist`) (`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"`) | | `--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`) |
@ -59,7 +59,7 @@ vitepress preview [root]
### Options ### Options
| Option | Description | | Option | Description |
| - | - | | --------------- | ------------------------------------------ |
| `--base <path>` | Public base path (default: `/`) (`string`) | | `--base <path>` | Public base path (default: `/`) (`string`) |
| `--port <port>` | Specify port (`number`) | | `--port <port>` | Specify port (`number`) |

@ -35,6 +35,11 @@ export async function build(
delete buildOptions.mpa delete buildOptions.mpa
} }
if (buildOptions.outDir) {
siteConfig.outDir = path.resolve(process.cwd(), buildOptions.outDir)
delete buildOptions.outDir
}
try { try {
const { clientResult, serverResult, pageToHashMap } = await bundle( const { clientResult, serverResult, pageToHashMap } = await bundle(
siteConfig, siteConfig,

@ -76,7 +76,7 @@ export async function bundle(
: typeof options.minify === 'boolean' : typeof options.minify === 'boolean'
? options.minify ? options.minify
: !process.env.DEBUG, : !process.env.DEBUG,
outDir: ssr ? config.tempDir : options.outDir || config.outDir, outDir: ssr ? config.tempDir : config.outDir,
cssCodeSplit: false, cssCodeSplit: false,
rollupOptions: { rollupOptions: {
...rollupOptions, ...rollupOptions,

Loading…
Cancel
Save