Chrome扩展程序+ create-react-app实时重新加载

Joã*_*uza 5 google-chrome-extension reactjs create-react-app

关于在使用create-react-app构建Chrome扩展程序时如何实现实时重新加载的任何建议?目前我yarn run build每次都有变化。

小智 2

我设法使用 create-react-app 通过以下方式做到这一点:

npm i npm-watch --save-dev
Run Code Online (Sandbox Code Playgroud)

然后在package.json中

{
    "name": "react-app",
    "version": "0.1.0",
    "private": false,
    "devDependencies": {
        "npm-watch": "^0.1.8",
        "react-scripts": "0.9.5",
    },
    "dependencies": {
        "react": "^15.4.2",
        "react-dom": "^15.4.2"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject",
        "watch": "npm-watch" //add this to the script
    },
    "watch": {  //add this outside the script
        "build": "src/"
    }
}
Run Code Online (Sandbox Code Playgroud)