Watchify不会发出更新事件

时间:2015-03-24 00:04:29

标签: javascript browserify watchify

我正在尝试使用watchify自动构建bundle.js,但遗憾的是,在保存文件时不会触发任何更新事件。

var bundler = watchify(browserify({
    debug: true,
    entries: ['./js/main.js'],
    transform: "babelify",
    cache: {}, packageCache: {}, fullPaths: true
  }))
  .on("update", function () {
    var updateStart = Date.now();
    console.log(updateStart);
    return bundler
      .bundle()
      .pipe(exorcist(path.join(distPath, "bundle.js.map")))
      .pipe(fs.createWriteStream(path.join(distPath, "bundle.js")));
  })
  .bundle()
  .pipe(exorcist(path.join(distPath, "bundle.js.map")))
  .pipe(fs.createWriteStream(path.join(distPath, "bundle.js")));

当我使用CLI时,行为类似:构建在启动后运行一次,就是它。

watchify ./js/main.js -o js-dist/bundle.js -v

我正在使用OS X Yosemite。

1 个答案:

答案 0 :(得分:-1)

我遇到了同样的问题。我使用了gulp repro的食谱。第一个bundlejs任务按预期工作。但是当我改变其中一个依赖关系时,就会发生这种情况。

似乎没有运行更新功能。但是,将重新编译main.js文件中所做的更改。所以不知何故重新运行任务,但是使用缓存的依赖项。

相关问题