unplugin / unplugin-vue-components

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

ant-design-vue4.x importStyle css-in-js 在使用了StyleProvider组件后编译报错 #749

Open muyi0728 opened 1 month ago

muyi0728 commented 1 month ago

Describe the bug

[vite] Pre-transform error: Failed to resolve import "ant-design-vue/es/style-provider/style" from "src/App.vue". Does the file exist? 5:56:19 PM [vite] Internal server error: Failed to resolve import "ant-design-vue/es/style-provider/style" from "src/App.vue". Does the file exist? Plugin: vite:import-analysis File: /Users/yangcebin/lzjy/company-console-front/src/App.vue:2:86 1 | / unplugin-vue-components disabled /import { ConfigProvider as unplugin_components_1 } from 'ant-design-vue/es';import 'ant-design-vue/es/config-provider/style'; 2 | import { StyleProvider as unplugin_components_0 } from 'ant-design-vue/es';import 'ant-design-vue/es/style-provider/style'; | ^ 3 | import { onBeforeUnmount, getCurrentInstance } from 'vue'; 4 | import zhCN from 'ant-design-vue/es/locale/zh_CN'; at formatError (file:///Users/yangcebin/lzjy/company-console-front/nodemodules/.pnpm/vite@5.2.11@types+node@20.12.8_less@4.2.0/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:50830:46)

Reproduction

1

System Info

vite 5.2.11
unplugin-vue-components 0.27.0
vue 3.4.26

Used Package Manager

pnpm

Validations

de1ck commented 1 week ago

目前使用 importStyle false 解决, antd4.x 自带按需样式加载 可以使用 resolvers: [ AntDesignVueResolver({ importStyle: false, }), ]