antd的样式引入
https://zhuanlan.zhihu.com/p/42313148
在做项目的时候,直接npm install antd 然后import {Input} from "antd"这样来使用的时候发现没有样式,所以需要在webpack中加入一些配置来实现按需引用antd的样式,方法如下:
安装插件babel-plugin-import
npm installl babel-plugin-import
.babelrc配置修改
{
"presets": [
"env","react","stage-0"
],
"plugins": [
"syntax-dynamic-import",
"transform-runtime",
[
"import",
{
"libraryName": "antd",
"style": "css"
}
]
]
}
其中
[
"import",
{
"libraryName": "antd",
"style": "css"
}
]
]
这个就是用来实现按需加载antd的样式的
如果babel的配置写在webpack.config.js中,写法样式参考webpack官网。