Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VitePress fails to start with @vitejs/plugin-vue in Vite config #4442

Closed
4 tasks done
chengbotao opened this issue Dec 24, 2024 · 2 comments
Closed
4 tasks done

VitePress fails to start with @vitejs/plugin-vue in Vite config #4442

chengbotao opened this issue Dec 24, 2024 · 2 comments
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@chengbotao
Copy link

Describe the bug

When I integrate VitePress into a Vue + TypeScript project created with Vite, VitePress fails to start if the @vitejs/plugin-vue plugin is included in the plugins array of vite.config.ts. However, VitePress starts successfully if I remove the @vitejs/plugin-vue plugin from the configuration.

Reproduction

  1. Create a Vue + TypeScript project using Vite.
  2. Integrate VitePress into the project.
  3. Include @vitejs/plugin-vue in the plugins array of vite.config.ts.
  4. Attempt to start VitePress, which results in an error and prevents it from starting.
  5. Remove @vitejs/plugin-vue from vite.config.ts.
  6. VitePress starts successfully without the plugin.

Expected behavior

VitePress should be able to start without any issues even with @vitejs/plugin-vue included in the vite.config.ts configuration.

System Info

Node.js 版本:18.16.1
npm/yarn/pnpm 版本:pnpm-9.2.0
Vite 版本:6.0.5
VitePress 版本:1.5.0
操作系统:macOS Sequoia 15.2

Additional context

image

stackblitz demo

Validations

@chengbotao chengbotao added the bug: pending triage Maybe a bug, waiting for confirmation label Dec 24, 2024
@brc-dd
Copy link
Member

brc-dd commented Dec 24, 2024

This is because vitepress adds that plugin by default, duplicating it in the chain. You can add this to .vitepress/config.ts

  vite: {
    configFile: false
  }

It will disable vite.config.ts auto-discovery when running vitepress. You'll need to copy any additional vite settings (except vue plugin) in .vitepress/config.ts too.

Alternatively you can configure a different root for vitepress (i.e. keep it inside docs/ or something instead of using cwd as root for both your vite app and docs).

@brc-dd brc-dd closed this as completed Dec 24, 2024
@chengbotao
Copy link
Author

Your reply has resolved my issue, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants