简体   繁体   English

Watchify不发出更新事件

[英]Watchify doesn't emit update event

I'm trying to build my bundle.js automatically with watchify, but unfortunately no update event is ever triggered when I save files. 我正在尝试使用bundle.js自动构建我的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")));

When I use CLI the behavior is similar: Build runs once after start and that's it. 当我使用CLI时,行为类似:构建在启动后运行一次,仅此而已。

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

I'm using OS X Yosemite. 我正在使用OS X Yosemite。

I am having the same problem. 我有同样的问题。 I used the recipes from the gulp repro. 我用了从gulp repro的食谱。 The first bundlejs task works as expected. 第一个bundlejs任务按预期工作。 However when I make changed to one of the dependencies nothings happens. 但是,当我更改为依赖项之一时,什么也没有发生。

It seems like the update functions is not being ran. 似乎没有运行更新功能。 However, changes made in main.js files are recompiled. 但是,将重新编译main.js文件中所做的更改。 So somehow the task is rerun, but with cached dependencies. 因此,该任务以某种方式重新运行,但是具有缓存的依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM