Skip to content

Commit fc2283d

Browse files
committed
check for compiler.hooks
1 parent 5f75900 commit fc2283d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/virtual.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ function VirtualModulesPlugin(compiler) {
3232
};
3333
}
3434

35-
compiler.hooks.watchRun.tapAsync('VirtualModulesPlugin', (watcher, callback) => {
35+
const watchRunHook = (watcher, callback) => {
3636
this._watcher = watcher.compiler || watcher;
3737
callback();
38-
});
38+
};
39+
40+
if (compiler.hooks) {
41+
compiler.hooks.watchRun.tapAsync('VirtualModulesPlugin', watchRunHook);
42+
} else {
43+
compiler.plugin('watch-run', watchRunHook);
44+
}
3945
}
4046

4147
VirtualModulesPlugin.prototype.writeModule = function(filePath, contents) {

0 commit comments

Comments
 (0)