1. 安装模块
$ yarn add react-app-rewired customize-cra babel-plugin-import less less-loader
2. 修改 package.json
/* package.json */
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewireds build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
}
3. 新建 config-overrides.js 并输入
const {override, fixBabelImports,addLessLoader} = require('customize-cra');
module.exports = override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}),
addLessLoader({
lessOptions: {
javascriptEnabled: true,
modifyVars: {'@primary-color': '#1DA57A'},
}
}),
);
正文完