ant-design-vue
ant-design-vue copied to clipboard
Failed to resolve import "ant-design-vue/es/default/style/css.js" from "src/entry/main.js". Does the file exist?
- [x] I have searched the issues of this repository and believe that this is not a duplicate.
Version
1.7.7
Environment
vue:2.7.0/vite:3.2.4/
Reproduction link
https://github.com/vueComponent/ant-design-vue
Steps to reproduce
pnpm run build
What is expected?
build sucess
What is actually happening?
error during build: Error: Failed to resolve import "ant-design-vue/es/default/style/css.js" from "src/entry/main.js". Does the file exist?
need reproduce
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
same issue
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
vue version: 3.4.21 This issue accured after I used unplugin-vue-components to load antd-vue components. My config is like this:
import Components from "unplugin-vue-components/vite"
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx(),
Components({
resolvers: [AntDesignVueResolver()],
dts: true
})
],
...
Found the key! Just add importStyle: 'css-in-js' or 'less' to the resolver, it works:
resolvers: [
AntDesignVueResolver({
// importStyle: 'css-in-js'
importStyle: 'less'
})
]
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days