# auto-import-antd

Latest version **0.1.2** (published 2023-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install auto-import-antd
pnpm add auto-import-antd
yarn add auto-import-antd
bun add auto-import-antd
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-12-18 |
| First published | 2023-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | estjs |
| Keywords | unplugin, vite, react, ant-design, auto import |

## Links

- npm: https://www.npmjs.com/package/auto-import-antd
- Repository: https://github.com/jiangxd2016/auto-import-antd
- Homepage: https://github.com/jiangxd2016/auto-import-antd#readme
- Issues: https://github.com/jiangxd2016/auto-import-antd/issues
- npm.io page: https://npm.io/package/auto-import-antd

## Dependencies (1)

- [unplugin-auto-import](https://npm.io/package/unplugin-auto-import.md) ^0.17.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2023-12-18

## README

# unplugin-auto-import-antd


> 仅支持 antd v5+.

## 特性

- 支持 `Vite`, `Webpack` 等
- 支持自动引入 `antd` 组件
- 支持使用自定义前缀重命名组件
- 支持通过包的别名引入

## 安装

### npm

```bash
npm i -D unplugin-auto-import-antd unplugin-auto-import
```

### yarn

```bash
yarn add -D unplugin-auto-import-antd unplugin-auto-import
```

### pnpm

```bash
pnpm add -D unplugin-auto-import-antd unplugin-auto-import
```

### bun

```bash
bun add -D unplugin-auto-import-antd unplugin-auto-import
```

## 使用

### Vite

```ts
// vite.config.ts
import AutoImport from 'unplugin-auto-import/vite'
import AntdResolver from 'unplugin-auto-import-antd'

export default defineConfig({
  plugins: [
    AutoImport({
      resolvers: [AntdResolver()]
    })
  ]
})
```

### Webpack

```js
// webpack.config.js
const AntdResolver = require('unplugin-auto-import-antd')

module.exports = {
  /* ... */
  plugins: [
    require('unplugin-auto-import/webpack')({
      resolvers: [AntdResolver()]
    })
  ]
}
```

### 自定义前缀

```ts
// vite.config.ts
import AutoImport from 'unplugin-auto-import/vite'
import AntdResolver from 'unplugin-auto-import-antd'

export default defineConfig({
  plugins: [
    AutoImport({
      resolvers: [
        AntdResolver({
          prefix: 'A'
        })
      ]
    })
  ]
})
```

使用自定义前缀，如 `A`, 书写组件的方式有原本的 `Button` 变为 `AButton`。

等价于 `import { Button as AButton } from 'antd'`

### 包别名引入

```ts
// vite.config.ts
import AutoImport from 'unplugin-auto-import/vite'
import AntdResolver from 'unplugin-auto-import-antd'

export default defineConfig({
  plugins: [
    AutoImport({
      resolvers: [
        AntdResolver({
          packageName: 'antd-v5'
        })
      ]
    })
  ]
})
```

通过别名安装 antd，如 antd-v5。

等价于 `import { Button } from 'antd-v5'`

---
_Source: https://npm.io/package/auto-import-antd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
