CRACO 快速使用
Getting Started | CRACO
craco 是专门由于 cra 配置的重写,扩展配置 cra (webpack)。
-
安装依赖
npm i -D @craco/craco
-
根目录下创建 craco.config.js 和配置 configure:
my-app ├── node_modules + ├── craco.config.js └── package.json
craco.config.js
module.exports = { devServer: { proxy: { '/api': { target: 'http://localhost:3000', changeOrigin: true, } } } }
-
脚本更改:
package.json
"scripts": { - "start": "react-scripts start" + "start": "craco start" - "build": "react-scripts build" + "build": "craco build" - "test": "react-scripts test" + "test": "craco test" }