How do we watch for changes?

Right now we are in a pickle. We need to re-run our compile task each time we make a change. Obnoxious… let’s fix this — it’s so simple!

We can specify arguments for webpack — type webpack -help in the terminal. This is what we should see.

Browsing through webpack options

As you noticed, webpack has a --watch or --w for short command. We can watch for changes! Very cool!

Let’s try it! type the watch command in your terminal.

webpack --watch

Let’s make add a new sentence to our index.js — make sure webpack is running with the watch method!

Open index.html with and wolaa!

Before we move on, let’s add our webpack watch method to the npm scripts.

Now we can use npm run watch for our webpack watch!