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

Ability to extend vite config #241

Closed
TheDutchCoder opened this issue Feb 16, 2021 · 12 comments
Closed

Ability to extend vite config #241

TheDutchCoder opened this issue Feb 16, 2021 · 12 comments

Comments

@TheDutchCoder
Copy link

Is your feature request related to a problem? Please describe.
Currently there seems to be no way to extend the Vite config used by vitepress (or at least it's not clear how to do it).
It would be great to have that ability to specify aliases that are used inside of components that are not part of VitePress.

In our case we have a component library in src, and the docs in docs, but components imported in VitePress use #components/button imports (for example) and VitePress can't resolve those as there's no way to set up aliases for it.

Describe the solution you'd like
A way to extend vite config and/or specify aliases.

Describe alternatives you've considered
I tried creating a vite config in the root, but that prevents TS based SFC's from compiling properly (I think it overwrites the internal config).

Additional context
A quick screenshot of our setup:
image

docs/.vitepress hosts VitePress, but the root is Vite itself (library mode).

@TheDutchCoder
Copy link
Author

TheDutchCoder commented Feb 16, 2021

I do see an alias option in here: https://github.com/vuejs/vitepress/blob/master/src/node/config.ts which might be what I'm looking for, though I haven't been able to get it to work yet.

Alias is deprecated though, so that doesn't seem to work.

Yeah it looks like recolve.alias in Vite is not something that's picked up by the VitePress config.

@yyx990803
Copy link
Member

If you put a vite.config.js in the VitePress (docs) root it will be picked up by VitePress.

@TheDutchCoder
Copy link
Author

Yeah I discovered that, but then it'll fail to compile SFC's. I assume because it needs some additional config for that, but wouldn't I at that point be rewriting whatever VitePress has built in?

@yyx990803
Copy link
Member

Hmm, not sure. It works as expected in the Vue blog: https://github.com/vuejs/blog/blob/master/vite.config.js

@TheDutchCoder
Copy link
Author

🤔 strange. Let me experiment with this some more.

Should it just merge the configs though?
In my use case I wanted the aliases to work (VitePress and Vite have slightly different configs for that) but I couldn't get it to work (Vite works fine with resolve.alias, but VitePress does not).

@kiaking
Copy link
Member

kiaking commented Apr 8, 2021

@TheDutchCoder Do you have any updates on this? 👀 If not, maybe we could close this one for now and open another issue if you encounter the issue again.

@kiaking kiaking added the need more info Further information is requested label Apr 8, 2021
@antfu
Copy link
Member

antfu commented Apr 8, 2021

Maybe due to this vitejs/vite#2847

@kiaking kiaking removed the need more info Further information is requested label Apr 8, 2021
@kiaking
Copy link
Member

kiaking commented Apr 8, 2021

Oh OK cool. Let's see how it goes with that issue then.

@kiaking
Copy link
Member

kiaking commented Apr 15, 2021

@antfu OK seems like Vite PR is merged. Is it already released? If so, all we need to do is upgrade Vite version right 👀 ?

@patak-dev
Copy link
Member

The PR has been merged, but it is not yet released. I'll ping here when this fix is included in the next release

@kiaking
Copy link
Member

kiaking commented Apr 15, 2021

@patak-js Great! Thanks 🤝

@patak-dev
Copy link
Member

@kiaking vitejs/vite#2847 has been released in v2.2.0

@antfu antfu closed this as completed Apr 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants