react

ui框架 ant design

yarn add antd
npm i -S less less-loader

相关文档:https://ant.design/docs/react/getting-started-cn

     http://www.codes51.com/itwd/4127276.html

按需加载 babel-plugin-import

在.babelrc文件中加入

"plugins": [
    ["import", { "libraryName": "antd", "style": "css" }] // `style: true` 会加载 less 文件
  ]

有的版本可能不生效,加到webpackconfig loader下的 js中尝试(网摘,没试过)

loaders: [
...
{
text: /\.(js|jsx)$/,
include: paths.appSrc,
loader: 'babel',
query: {
cacheDirectory: true,
plugins: [["import", { libraryName: "antd", style: "css" }]]
}
},
...
]

 

 

create-react-app 中修改配置,react中对webpack配置做了封装,需要在node_modules/react-scripts/config中做对应的修改

posted on 2017-10-24 16:50  前路亦是故乡  阅读(142)  评论(0编辑  收藏  举报

导航