安装

  1. yarn add mobx mobx-react -S
  1. yarn add -D react-app-rewired customize-cra @babel/plugin-proposal-decorators

配置

在根目录下新建config-overrides.js

  1. const { override, addDecoratorsLegacy } = require("customize-cra")
  2. module.exports = override(
  3. addDecoratorsLegacy()
  4. )

在package.json

  1. "scripts": {
  2. "start": "react-app-rewired start",
  3. "build": "react-app-rewired build",
  4. "test": "react-app-rewired test --env=jsdom" ,
  5. "eject": "react-scripts eject"
  6. },