react的src配置成@
作者:互联网
背景 react的src配置成@
新建文件:config-overrides.js 放在根目录下
const { override } = require("customize-cra");
// import { override } from "customize-cra";
const path = require("path");
module.exports = override((config) => {
config.resolve.alias = {
"@": path.resolve(__dirname, "src"),
};
return config;
});
## 修改package.js文件内容
```js
//修改这部分内容
"scripts": {
"start": "react-app-rewired start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
启动报错解决办法
重新安装
npm install react-app-rewired customize-cra --save
ok
标签:src,customize,配置,js,react,scripts,override,config 来源: https://www.cnblogs.com/ministep/p/15358261.html