ant-design / ant-design-icons

⭐ Ant Design SVG Icons
https://ant.design/components/icon/
MIT License
940 stars 577 forks source link

[Help] How to use it with `babel-plugin-import`. #154

Open xyy94813 opened 4 years ago

xyy94813 commented 4 years ago

Now, I only use a few icons in @ant-design/icons.

I will use more in the future, but I definitely can't use all the icons.

When i import @ant-design/icons like this:

import { AntDesignOutline, DashboardOutline, TwitterOutline } from '@ant-design/icons';
import AntdIcon from '@ant-design/icons-react';

AntdIcon.add(AntDesignOutline, DashboardOutline);

Webpack bundle all icons, including what I didn't use.

I am not sure if I can use it with babel-plugin-import.

It is awesome, if we can dynamic import icons just like antd

kckusal commented 3 years ago

Any updates on this?

xyy94813 commented 3 years ago

I don't know if it works well

[
  "import",
    {
      "libraryName": "@ant-design/icons",
      "customName": (name, file) => {
          // do something in this
          // return `libs/${name}`
       }
    }
]