You may need CRACO.
Create React App Configuration Override is an easy and comprehensible configuration layer for create-react-app.
$ npm install @craco/craco --save
Create a craco.config.js
file in the root directory and configure CRACO:
my-app
├── node_modules
├── craco.config.js
└── package.json
Update package.json
:
/* package.json */
"scripts": {
- "start": "react-scripts start",
+ "start": "craco start",
- "build": "react-scripts build",
+ "build": "craco build"
- "test": "react-scripts test",
+ "test": "craco test"
}
Finally, edit craco.config.js
file:
module.exports = {
devServer: (devServerConfig) => {
devServerConfig.writeToDisk = true;
return devServerConfig;
},
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…