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中做对应的修改

开黑吗我亚索贼6
原文地址:https://www.cnblogs.com/insight0912/p/7724446.html