创建demo脚手架
create-react-app demo
react的webpack配置默认不可显,该命令可显示config
npm run eject
安装babel按需加载依赖
npm i babel-plugin-import --save-dev
package.json添加下列配置
"plugins": [
["import",{"libraryName": "antd","libraryDirectory": "es","style": "css"}]
]
使用组件可直接引入 css会按需加载
import { Button } from 'antd'
网友评论