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" work with "unplugin-vue-components" bug #4519

Closed
4 tasks done
huchaomin opened this issue Jan 25, 2025 · 6 comments
Closed
4 tasks done

"vitepress" work with "unplugin-vue-components" bug #4519

huchaomin opened this issue Jan 25, 2025 · 6 comments
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@huchaomin
Copy link

huchaomin commented Jan 25, 2025

Describe the bug

all auto import components in dev mode is ok.
all auto import components in build mode is ok, when there have no 'script' tag in md files

if md file have 'script' tag of one page. the page's auto import component will not resolve in build mode!!!!

Reproduction

it's an empty vitepress project.

Reproduction URL

Expected behavior

Image Image Image Image

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (28) x64 Intel(R) Core(TM) i7-14700KF
    Memory: 15.99 GB / 31.82 GB
  Binaries:
    Node: 20.17.0 - D:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - D:\Program Files\nodejs\npm.CMD
    pnpm: 9.8.0 - D:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    vitepress: ^1.6.3 => 1.6.3

Additional context

No response

Validations

@huchaomin huchaomin added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 25, 2025
@brc-dd
Copy link
Member

brc-dd commented Jan 25, 2025

That repository is empty. Forgot to push?

@huchaomin
Copy link
Author

That repository is empty. Forgot to push?

sorry, i have pushed now

@brc-dd
Copy link
Member

brc-dd commented Jan 25, 2025

Update the includes to this:

include: [/\.(vue|md)($|\?)/]

https://github.com/unplugin/unplugin-vue-components/blob/2efdaac67970c4a0582ef475cd583e30e42791e4/examples/vite-vue3/vite.config.ts#L29

@brc-dd brc-dd closed this as completed Jan 25, 2025
@userquin
Copy link
Member

I use this at pwa docs (https://github.com/vite-pwa/docs/blob/main/vite.config.ts#L36-L56):

      // allow auto load markdown and vue components under `./components/`
      extensions: ['vue', 'md'],

      // allow auto import and register components used in markdown
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],

@huchaomin
Copy link
Author

Update the includes to this:

include: [/.(vue|md)($|?)/]
https://github.com/unplugin/unplugin-vue-components/blob/2efdaac67970c4a0582ef475cd583e30e42791e4/examples/vite-vue3/vite.config.ts#L29

good! it works! thank you so much!

@brc-dd
Copy link
Member

brc-dd commented Jan 25, 2025

@userquin OP also had that. But /\.md$/ wasn't matching import when <script setup lang=ts> was used in markdown. The import is like this in that case:

import _sfc_main from "/Users/divyansh/vitepress-auto-import-bug/index.md?vue&type=script&setup=true&lang.ts";

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

3 participants