I am trying to set up a serve
task that will do the following:
- Call a
watch
task to watch for any source changes. ( the watch task calls abuild
task that builds the app into a "build" folder ) - Start the app using Nodemon ( gulp-nodemon )
- If a source change happens - rebuild the app and restart nodemon
So far I've written the following tasks:
gulp.task('build', gulp.series(['lint'], () => {
del.sync(['./build/**/*.*']);
const tsCompile = gulp.src('./src/**/*.ts')
.pipe(gulpSourcemaps.init())
.pipe(project());
return tsCompile.js.pipe(gulpSourcemaps.write({
sourceRoot: file => path.relative(path.join(file.cwd, file.path), file.base)
}))
.pipe(gulp.dest('./build/'));
}));
gulp.task('watch', gulp.series(['build'], () => {
gulp.watch('./src/**/*.ts', gulp.series(['build']));
}));
gulp.task('serve', gulp.series(['watch'], () => {
return gulpNodemon({
script: './build/index.js',
watch: './build/'
});
}));
The current behavior of the tasks is:
- I start the application by typing
gulp serve
- The
watch
tasks is called and it works as expected - Nodemon does not start and the process is stuck at the
watch
task. If I change any of the source code, thewatch
task will be called.
Basically, Nodemon does not start and only the watch
task is working.
I am not able to figure out why the following behavior happens and I want to ask if anyone knows what the problem could be?