Reputation: 71
I'm figuring out how gulp is working; it looks like the gulp tasks are being executed, but then it hangs.
Environment:
node version
v14.17.0.
gulp:
CLI version: 2.3.0 Local version: 4.0.2
const babel = require("gulp-babel");
task("js",()=>{
return src("src/*.js").pipe(babel()).pipe(dest("dist/js"));
})
task("moveHTML",()=>{
return src("src/*.html").pipe(dest("dist"));
});
task("watch",()=>{
watch("src/*.js",series("js"));
});
task("default",series('moveHTML','js','watch'));
There is no error here, but the execution is hanging. below is the node terminal message:
[10:30:29] Starting 'default'...
[10:30:29] Starting 'moveHTML'...
[10:30:29] Finished 'moveHTML' after 85 ms
[10:30:29] Starting 'js'...
[10:30:32] Finished 'js' after 3.22 s
[10:30:32] Starting 'watch'...
Upvotes: 1
Views: 636
Reputation: 13580
The process persists because you are calling gulp.watch
which returns an instance of chokidar
and by default keeps the node process running.
If you want to stop the node process use the persistent
option and set it to false
.
watch("src/*.js", { persistent: false }, series("js"));
However, the gulp docs suggest not to do this.
Upvotes: 2