antd 按需引入并配置config-overrides.js

第一步:安装antd

npm add antd

第二步:下载依赖包(定义组件按需打包)

npm install react-app-rewired customize-cra babel-plugin-import 

第三步:安装 @babel/plugin-proposal-decorators

npm add @babel/plugin-proposal-decorators

第四步: 配置config-overrides.js

// 
const {
  override,
  addDecoratorsLegacy
} = require("customize-cra")

module.exports = override (
  // 配置装饰器
  addDecoratorsLegacy()
)

第五步:配置package.json中的scripts启动项

 "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react--app-rewired test",
    "eject": "react-scripts eject"
  }

你可能感兴趣的:(react)