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']);
});