【问题标题】:Watchify doesn't emit update eventWatchify 不发出更新事件
【发布时间】:2015-05-27 04:16:28
【问题描述】:

我正在尝试使用 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。

【问题讨论】:

    标签: javascript browserify watchify


    【解决方案1】:

    我也有同样的问题。我使用了 gulp repro 的食谱。第一个 bundlejs 任务按预期工作。但是,当我更改依赖项之一时,什么都没有发生。

    似乎没有运行更新功能。但是,在 main.js 文件中所做的更改会被重新编译。因此,任务以某种方式重新运行,但具有缓存的依赖项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-21
      • 2015-07-11
      • 2016-02-25
      • 1970-01-01
      • 2014-11-12
      • 2017-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多