react中create-react-app配置antd按需加载(方法二)

1.yarn add babel-plugin-import

2.在根目录下的package.json下的bable中添加相应代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"babel": {
"presets": [
"react-app"
],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": "css"
// 引入样式为 css
// style为true 则默认引入less
}
]
]
}

3.重启项目yarn run start

#

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×