unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.68k stars 342 forks source link

为什么将node_modules里面的未编译的vue文件加入AntDesignVueResolver后无效 #654

Closed lllianreg closed 10 months ago

lllianreg commented 1 year ago

Describe the bug

// private-component-library/demo.vue
<a-tabs v-model:activeKey="tabKey">
// TODO
</a-tabs>

// vite.config.js
Components({
    resolvers: [AntDesignVueResolver({
      exclude: ['AModal']
    })],
    include: [/[\\/]node_modules[\\/]private-component-library/, /\.vue$/, /\.vue\?vue/]
 }),

结果 Snipaste_2023-07-07_11-43-15

Reproduction

test

System Info

win32

Used Package Manager

npm

Validations

lllianreg commented 1 year ago

解决了

exclude: [/[\\/]node_modules[\\/]((?!private-component-library|private-component-library-vite\/).)/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]

另外 如果引入了cdn 需要 externals

import { viteExternalsPlugin } from 'vite-plugin-externals'
plugins.viteExternalsPlugin((isPro ? {
  vue: 'Vue',
} : {}),)
vivid05 commented 11 months ago

vite-plugin-externals

跟vite-plugin-cdn-import这个插件一起用会有冲突,有解决方案不