1.安装craco:
yarn add @craco/craco or npm i @craco/craco
- 安装好,修改
"scripts": {
- "start": "react-scripts start",
- "build": "react-scripts build",
- "test": "react-scripts test",
- "start": "craco start",
- "build": "craco build",
- "test": "craco test",
}
- 安装 yarn add craco-less,新建craco.config.js 和
添加
const CracoLessPlugin = require('craco-less');
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': '#1DA57A' },
javascriptEnabled: true,
},
},
},
},
],
};