-
npm install antd -S
- 在src文件夹下新建config-overrides.js
const { override, fixBabelImports, addDecoratorsLegacy, } = require("customize-cra"); module.exports = override( fixBabelImports("import", { //antd按需加载 // npm install react-app-rewired customize-cra babel-plugin-import -D libraryName: "antd", libraryDirectory: "es", style: "css" }), // 配置装饰器 // npm install -D @babel/plugin-proposal-decorators addDecoratorsLegacy(), );
- 然后
- npm install react-app-rewired customize-cra babel-plugin-import -D
- 需要配置装饰器的
- npm install -D @babel/plugin-proposal-decorators
- 最后修改package.js
"scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", "eject": "react-app-rewired eject" },