npm run eject报错

1
2
git add .
git commit -m "init"
1
2
3
yarn add less less-loader
yarn add customize-cra
yarn add react-app-rewired

修改 package.json 里面的启动项

1
2
3
4
5
6
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
},

使用 babel-plugin-import 实现 antd 的按需加载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
npm install --save-dev babel-plugin-import
//再修改 config-overrides.js
const {
override,
fixBabelImports,
addLessLoader,
} = require("customize-cra");


module.exports = override(
fixBabelImports("import", {
libraryName: "antd", libraryDirectory: "es", style: true // change importing css to less
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: { "@primary-color": "#1DA57A" }
})
);

antd-schema-form
npm install babel-loader babel-core babel-preset-es2015 –save
npm install –save-dev @babel/plugin-proposal-decorators