unplugin-icons: There are tsx and vue files in the project, can't both files be automatically imported?
In the .vue file, it works fine
// vite.config.ts
IconsResolver({
enabledCollections: ['ep']
})
But in tsx, I tried to write like this, but it didn’t work😢
// vite.config.ts
plugins: [
Icons({
jsx: 'react', // 'react' or 'preact'
compiler: 'jsx', // 'vue2', 'vue3', 'jsx'
}),
// Api自动导入
AutoImport({
resolvers: [
IconsResolver({
prefix: 'i', // 图标前缀,默认为i
enabledCollections: ['ep'],
extension: 'jsx',
}),
],
}),
// 按需导入组件
Components({
resolvers: [
// 自动注册图标组件
IconsResolver({
prefix: 'i', // 图标前缀,默认为i
extension: 'jsx',
enabledCollections: ['ep'],
}),
],
}),
],
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (12 by maintainers)
@userquin OK, thank you very much!👍🥰
in fact, we can remove the last resolver in the components plugin: https://github.com/userquin/vue-super-admin-unplugin-icons-221/commit/5351f8e4c373aa35cddcb405430e1165c24f9690
so, in summary:
vueJsxpluginwe need to include the unplugin icons twice to support vue and jsx: it will also work without the jsx (theincludein the components plugin do the trick)includeon auto import and components pluginall the icons will be Vue componentsthe icons were always Vue components 😉EDIT: we don’t need to configure the unplugin icons for jsx: https://github.com/userquin/vue-super-admin-unplugin-icons-221/commit/a48ad8a9bba9491921abe32e993ea9b0bd944d91
@userquin thank you, my friend. However, you need to wait for a while, I will provide you with it when I get home from getting off work later~ 😂
about an hour later…