Automatic build in Webpack
You can make Webpack track changes to project files and run the build itself every time. To do this, you need to make the following setting in scripts:
"watch": "webpack --mode development --watch"
As a result, our package.json file will look like this:
"scripts": {
"build": "webpack",
"dev": "webpack --mode development",
"prod": "webpack --mode production",
"watch": "webpack --mode development --watch"
},
You can start file tracking with the following command:
npm run watch
After this, you won't be able to enter any commands into the terminal until you interrupt monitoring with the Ctrl + C command.
Update your package.json with the appropriate settings.
Run Webpack in watch mode.
Make changes to the project files. Check that the automatic build will occur.
Stop tracking with the appropriate command.