创建react项目
create-react-app mobx-demo cd my-app npm run start
使用react-app-rewired
npm install customize-cra react-app-rewired @babel/plugin-proposal-decorators --save
在你的根目录即 和src同级的地方新建js文件 config-overrides.js 粘贴下方代码:
const{override,addDecoratorsLegacy}=require('customize-cra'); module.exports=override(addDecoratorsLegacy());
修改package.json 的scripts如下:
"scripts":{ "start":"react-app-rewired start", "build":"react-app-rewired build", "test":"react-app-rewired test", "eject":"react-app-rewired eject" }
链接:https://www.jianshu.com/p/a7b19953ce46