Skip to content

support specifying outDir in vitepress preview #4073

@ghost

Description

Describe the bug

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

  • default script: "docs:build": "vitepress build" builds the ./.vitepress/dist folder;
  • custom script: "docs:build": "vitepress build --outDir './dist"' builds the ./dist folder.

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

  • default script: "docs:preview": "vitepress preview" considers the ./.vitepress/dist folder;
  • custom script: there is no way to preview the project that was built on the ./dist folder.

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.

Activity

ghost added on Jul 22, 2024
brc-dd

brc-dd commented on Jul 25, 2024

@brc-dd
Member

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.

changed the title [-]'vitepress preview' command only considers the default dist folder[/-] [+]support specifying `outDir` in `vitepress preview`[/+] on Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @brc-dd

        Issue actions

          support specifying `outDir` in `vitepress preview` · Issue #4073 · vuejs/vitepress