-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (23 loc) · 706 Bytes
/
index.js
File metadata and controls
27 lines (23 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var watch = require('watch');
var path = require('path');
var fs = require('fs');
function watchFilePlugin(options) {
this.options = options;
}
watchFilePlugin.prototype.apply = function(compiler) {
var that = this;
compiler.plugin("emit", function(compilation, callback) {
var watchFolder = that.options.watchFolder;
watch.createMonitor(watchFolder, function(monitor){
monitor.files[path.join(watchFolder, "/*."+that.options.watchExtension)]
monitor.on("changed", function (f, curr, prev) {
compiler.run(function(err) {
if(err) throw err;
monitor.stop();
});
});
});
callback();
});
};
module.exports = watchFilePlugin;