How to compile only the modified files in gulp.watch

2

I have a typescript project and I'm using gulp as task manager . I want the gulp watch task to wait for the source code to be modified and recompile it, but since the source code is very long and it is divided into several files, I want it to only recompile those that are modified and not all. With gulp.watch(src, ['compile-src']); I execute the task compile-src every time any file is modified, but compile-src compiles me all the files.

This is my gulpfile:

const gulp = require('gulp');
// gulp + typescript specifics
const typescript = require('gulp-typescript');
const ts = typescript.createProject('./tsconfig.json');

const src = ['./src/**/*.ts', './test/**/*.ts'];

gulp.task('compile-src', () => {
    ts.src()
        .pipe(ts())
        .pipe(gulp.dest('dist'));
});

gulp.task('watch', ['compile-src'], () => {
    gulp.watch(src, ['compile-src']);
});
    
asked by Daniel Pérez 07.08.2017 в 19:51
source

1 answer

0

in Visual Studio Code, I open only the ones I'm going to modify. In integrated terminal (on the modified open file) I put in command line gulp sass; and compiles only that file.

    
answered by 20.06.2018 в 22:48