vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.04k stars 2.1k forks source link

support specifying `outDir` in `vitepress preview` #4073

Open ghost opened 3 months ago

ghost commented 3 months ago

Describe the bug

The vitepress build script recognizes the --outDir argument. For example,

However, the vitepress preview script cannot locally preview the project in a different folder. For example,

Workaround: setting '../dist' as the value of outDir option on config.js satisfies the expected result when running vitepress preview. The considered folder becomes ./dist as expected.

Reproduction

https://stackblitz.com/edit/vite-tyd3c7?file=package.json

Expected behavior

The script docs:preview correctly recognizes the modified outDir folder.

brc-dd commented 3 months ago

vitepress preview doesn't accept flags via CLI (except for base and port as the docs mention). You need to specify such things in config directly, or you can use some other server like npx serve ./path/to/your/dist which would work too.

vitepress serve is alias of vitepress preview. serve was there earlier, I'll update the command in stackblitz to align more for new users.