unplugin-antd-resolver
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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'

Package Sidebar

Install

npm i unplugin-antd-resolver

Weekly Downloads

5

Version

0.0.2

License

MIT

Unpacked Size

7.36 kB

Total Files

7

Last publish

Collaborators

  • liuxincai