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

Import a file that's not in the root directory #16

Closed
clemvnt opened this issue May 23, 2020 · 6 comments · Fixed by #59
Closed

Import a file that's not in the root directory #16

clemvnt opened this issue May 23, 2020 · 6 comments · Fixed by #59
Labels
enhancement New feature or request

Comments

@clemvnt
Copy link

clemvnt commented May 23, 2020

Is your feature request related to a problem? Please describe.

Currently, I have a directory structure like :

project/
├── dist/
├── docs/
│   ├── .vitepress/
│   └── index.md
├── src/
│   └── components/
├── package.json
└── ...

The docs directory contains a vitepress app.

If I'm not mistaken, that's not possible to import a file that's not in the docs directory (a .vue file from src directory for example).

Describe the solution you'd like

I don't know what's the best solution to this problem. But if we can add a custom vite resolver, it should work I guess ?

Moreover, it would also be necessary to expose the vite watcher instance to watch these resolved files.

Since the recent Vite features, we can alias a path to a fs directory, but in Vitepress, we can't override the vite configuration to add our aliases.

@yyx990803
Copy link
Member

That's a good point - should support passing options onto vite in VitePress' config file.

@yyx990803 yyx990803 added the enhancement New feature or request label Jun 5, 2020
agulado pushed a commit to agulado/vitepress that referenced this issue Mar 4, 2022
@adamdehaven
Copy link

adamdehaven commented Jun 12, 2022

This no longer appears to work, especially if the ../src/components/**/*.vue file utilizes a @/ alias for the src directory to import another file (e.g. you want to utilize components from the same repo inside the /docs directory)

@brc-dd
Copy link
Member

brc-dd commented Jun 12, 2022

@adamdehaven Hi, its working for me: https://github.com/brc-dd/vitepress-with-alias, can you create a separate issue with a minimal, reproducible example?

@adamdehaven
Copy link

@brc-dd what if your HelloWorld.vue component imports another component from /components, utilizing the @/ alias?

@brc-dd
Copy link
Member

brc-dd commented Jun 12, 2022

@adamdehaven You'll need a separate vite config file for that. I've updated the example.

@adamdehaven
Copy link

adamdehaven commented Jun 12, 2022

Hmm, I have that as well.

Edit: haven't had time to come back to this yet (sorry for commenting then disappearing)

@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
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants