Create React App does not provide watching build mode oficially (#1070).
This script provides watching build mode for an external tool such as Chrome Extensions or Firebase app. You can either build the dev bundle once with build:dev, or continually rebuild it with watch
Create a React app.
Put the script into scripts/build.js.
Add build:dev and watch tasks into the scripts block in package.json as follows:
"scripts": {
"start": "react-scripts start",
// Add next line
"build:dev": "node scripts/build.js",
"watch": "npm run build:dev --watch",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}Run the watch task.
npm run watchChange source code and check build output.
Directory structure may be following:
app/src/public/scripts/watch.js(need to add)
package.json(need to modify)build/(output)