pbialy
pbialy

Reputation: 1083

Restart Webpack every file change

I want my Webpack to reset everytime I change a file.

Currently I have a code like this:

watchOptions: {
  aggregateTimeout: 600,
  poll: true
},

(based on https://webpack.github.io/docs/cli.html#watchoptions-poll)

Which works, but not in the way I would like.

Expected:

Actual situation:

Any solutions / hints?

Or maybe it can't be done in Webpack?

Upvotes: 1

Views: 5616

Answers (1)

The Reason
The Reason

Reputation: 7983

Probably you coudn't understand how webpack works. It takes file from entry point.

webpack.config.js

{
  entry: "./app.js",
  output: {
    path: __dirname,
    filename: "bundle.js"
  }
}

if entry file has dependencies, it recursively take all of them and compile to a single file like bundle.js for example. So if you make a small changes into your file (doesnt matter which one), webpack should recompile all changes and give you new bundle.js file. If you look at this link you will see

Watch mode --

watch Watches all dependencies and recompile on change.

So your webpack works correct, it is impossible to get correct bundle.js file without compilation all your files

I hope it will help you.

Thanks

Upvotes: 1

Related Questions