1.安装craco
yarn add @craco/craco
2.修改 package.json
里的 scripts
属性
这里我整理了,直接复制过去就成
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
然后再app.js中引入
import 'antd/dist/antd.less';
4.安装craco
yarn add craco-less
5.新建craco.config.js
const CracoLessPlugin = require('craco-less');
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': 'red' },
javascriptEnabled: true,
},
},
},
},
],
};