0

There is the following gulp tasks:

// Processing templates task
gulp.task('templates', function() {
  return gulp.src('app/**/*.slim')
      .pipe(slim({pretty: true}))
      .pipe(minifyHTML())
      .pipe(gulp.dest(dist));
});

// Watching files for changes task
gulp.task('watch', function() {
    gulp.watch('app/**/*.slim', ['templates']); 
});

As you can see templates task finds and transforms all .slim files in .html file. It works good. Also there is watch task which watches changes and executes templates task after it. But I want that after watch task finds some changes in template A gulp will transform only template A, not all templates. I don't understand how I can get changed file and transform it. Please, help me. Thanks in advance.

Alexandr Lazarev
  • 12,554
  • 4
  • 38
  • 47
malcoauri
  • 11,904
  • 28
  • 82
  • 137
  • [See this question and its answers](https://stackoverflow.com/questions/23890806/how-to-run-a-task-only-on-modified-file-with-gulp-watch). – sdgluck Sep 11 '15 at 09:11

1 Answers1

2

I think you can try Incremental build.

gulp.task('default', function () {
    return gulp.src('app/**/*.slim')
        .pipe(watch('app/**/*.slim'))
        .pipe(slim({pretty: true}))
        .pipe(minifyHTML())
        .pipe(gulp.dest(dist));
});
Alexandr Lazarev
  • 12,554
  • 4
  • 38
  • 47