0

我在我的项目中使用gulp-newer来检查哪个 html 文件已被更新,并防止重新加载项目中的每个 html 文件。

除部分文件外,一切正常。

如果我在部分中编辑某些内容,则文件将正确更新,但我调用部分的文件将不会更新。

我看到有一个带有 gulp-newer 的options.extr,但不能使它工作。

我的想法是如果我更新其中一个部分中的某些内容,则重新加载每个 html 文件,如果我处理基本文件,则保持单个文件重新加载。

这是我的任务:

// COMPILE SLIM TO HTML
// ---------------------------------------------------------
gulp.task('slim', function () {
  return gulp.src(slim_dev + '/**/*.slim')
    // prevent server from crashing
    .pipe(plugins.plumber({ errorHandler: function(err) {
      plugins.notify.onError({
          title: "Gulp error in " + err.plugin
      })(err);
    }}))
    // compile slim to html
    .pipe(plugins.slim({
      pretty: false,
      include: true
    }))

    .pipe(plugins.newer('build/views/'))
    // minify html
    .pipe(plugins.minifyHtml())
    // copy result to build folder
    .pipe(gulp.dest(slim_build))
    // reload server on slim save
    .pipe(stream({once:true}))
    // notify when task completed
    .pipe(plugins.notify('Slim compilation completed !'));
});
4

0 回答 0