使用craco修改create-react-app的默认配置
2022-07-27 本文已影响0人
beijixing_233
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,
},
},
},
},
],
};