1、安装插件
1 2 3 |
npm i react-app-rewired -D npm i customize-cra -D npm i react-scripts -S |
2、在项目根目录创建 config-overrides.js
1 2 3 4 5 6 7 8 9 10 |
const { override, addWebpackAlias } = require('customize-cra') const path = require('path') const resolve = dir => path.join(__dirname, '.', dir) module.exports = override( addWebpackAlias({ ['@']: resolve('src') }) ) |
3、修改package.json
1 2 3 4 5 6 |
"scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", "eject": "react-app-rewired eject" }, |