Skip to content

Commit 42e5778

Browse files
committed
Merge pull request #32 from janraasch/feature/watch-options
Use watchOptions instead of solely allowing watchDelay
2 parents 4f2b09e + 9b5c207 commit 42e5778

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ app.use(webpackMiddleware(webpack({
4747
// switch into lazy mode
4848
// that means no watching, but recompilation on every request
4949

50-
watchDelay: 300,
51-
// delay after change (only lazy: false)
50+
watchOptions: {
51+
aggregateTimeout: 300,
52+
poll: true
53+
},
54+
// watch options (only lazy: false)
5255

5356
publicPath: "/assets/",
5457
// public path to bind the middleware to

middleware.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ var mime = require("mime");
99
// constructor for the middleware
1010
module.exports = function(compiler, options) {
1111
if(!options) options = {};
12-
if(options.watchDelay === undefined) options.watchDelay = 200;
12+
if(typeof options.watchOptions === "undefined") options.watchOptions = {};
13+
if(typeof options.watchDelay !== "undefined") {
14+
// TODO remove this in next major version
15+
console.warn("options.watchDelay is deprecated: Use 'options.watchOptions.aggregateTimeout' instead");
16+
options.watchOptions.aggregateTimeout = options.watchDelay;
17+
}
18+
if(typeof options.watchOptions.aggregateTimeout === "undefined") options.watchOptions.aggregateTimeout = 200;
1319
if(typeof options.stats === "undefined") options.stats = {};
1420
if(!options.stats.context) options.stats.context = process.cwd();
1521
if(options.lazy) {
@@ -94,7 +100,7 @@ module.exports = function(compiler, options) {
94100

95101
// start watching
96102
if(!options.lazy) {
97-
var watching = compiler.watch(options.watchDelay, function(err) {
103+
var watching = compiler.watch(options.watchOptions, function(err) {
98104
if(err) throw err;
99105
});
100106
} else {

0 commit comments

Comments
 (0)