unplugin-antd-resolver
v0.0.2
Published
unplugin-antd-resolver 用于在 unplugin-auto-import 中实现 antd 组件的按需引入。
Downloads
42
Maintainers
Readme
unplugin-antd-resolver
unplugin-antd-resolver
用于在 unplugin-auto-import 中实现 antd 组件的按需引入。。
仅支持 antd v5+.
安装
npm
npm i -D unplugin-antd-resolver unplugin-auto-import
yarn
yarn add -D unplugin-antd-resolver unplugin-auto-import
pnpm
pnpm add -D unplugin-antd-resolver unplugin-auto-import
使用
Vite
// vite.config.ts
import AutoImport from "unplugin-auto-import/vite";
import AntdResolver from "unplugin-antd-resolver";
export default defineConfig({
plugins: [
AutoImport({
resolvers: [AntdResolver()],
}),
],
});
自定义前缀
// vite.config.ts
import AutoImport from "unplugin-auto-import/vite";
import AntdResolver from "unplugin-antd-resolver";
export default defineConfig({
plugins: [
AutoImport({
resolvers: [
AntdResolver({
prefix: "Xt",
}),
],
}),
],
});
使用自定义前缀,如 Xt
, 组件的使用方式由原本的 Button
变为 XtButton
。
等价于 import { Button as AButton } from 'antd'