1、當你使用import { Button } from 'antd';這種方式引入組件的時候,沒有作處理的時候,會加載antd下的全部模塊,影響應用程序的網絡性能。babel
2、可使用使用import Button from 'antd/es/button'; import 'antd/es/button/style';這種方式按需加載。網絡
3、能夠繼續使用import { Button } from 'antd';這種方式。使用 babel-plugin-import 來進行按需加載。插件會幫你轉換成 antd/es/xxx 的寫法。另外此插件配合 style 屬性能夠作到模塊樣式的按需自動加載。或者能夠引入壓縮的全局樣式。antd
// .babelrc
{
"plugins": [["import", {
"libraryName": "antd",
"libraryDirectory": "es",// 默認是lib性能
"style": true
}spa
]]
}插件