A
A
Anton Essential2017-01-08 15:47:59
JavaScript
Anton Essential, 2017-01-08 15:47:59

How to rebuild exactly the file in which there were changes?

Good afternoon.
Probably someone knows how to compile only the file in which changes have occurred, for example, there are 20 files in the directory with the pug extension, there is a watcher that watches the change in the directory, when one file is changed, everyone is recompiled, mine is some kind of nonsense, when there are a lot of files, hellish pain begins, is it possible to monitor the file (it doesn’t matter which one) and if it has changed, compile it with its includes and not all 20.
I use gulp to build

// Pug task
    gulp.task('pug', function buildHTML(cb) {
      return gulp.src('pug/*.pug')
      .pipe(pug())
      .pipe(gulp.dest('./dist/'));
    });

    // Watch task
    gulp.task('watch',function(){
      global.isWatching = true;

      // Modules pug
      watch('pug/*.pug', function() {
        return runSequence('pug', browserSync.reload);
      });
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2017-01-08
@AntonEssential

In galpa 4 version out of the box, you can do this:

gulp.task( 'pug', function () {
  return gulp.src( 'pug/*.pug', { since: gulp.lastRun( 'pug' ) } )
  .pipe( pug() )
  .pipe( gulp.dest( './dist/' ) );
});

There is also gulp-newer .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question