How to auto import ant design vue component and styles in tsx or jsx?
MAXLZ1 opened this issue · 3 comments
MAXLZ1 commented
tsx component
export default defineComponent({
// ...
setup(props, { attrs }) {
// ...
return (): JSX.Element => {
return <Input {...attrs} />
}
},
})
vue.config.js
const Components = require('unplugin-vue-components/webpack')
const AutoImport = require('unplugin-auto-import/webpack')
module.exports = {
// ...
configureWebpack: {
plugins: [
Components({
resolvers: [
resolvers.AntDesignVueResolver({
resolveIcons: true,
importStyle: 'less',
})
]
}),
// How to set ?
AutoImport({
include: [
/\.[tj]sx?$/,
],
imports: [],
resolvers: (name) => {
console.log(name)
}
})
]
}
}
joker77877 commented
I have the same problem.
antfu commented
The current implementation does not support importing side-effects, contributions are welcome.
juetan commented
I try to import naive-ui components in vite, it works in .vue file, not in .tsx, maybe something missed. For resolver , I want auto import like this import { NButton } from 'naive'
,my resolver is like this: resolvers: (name) => { if(name.startWith('N')) { return { name, module: 'naive-ui' } } }
. hope it help you.