延迟吞咽手表 [英] Delay in gulp watch

查看:106
本文介绍了延迟吞咽手表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前我正在使用ftp并在服务器上运行gulp watch,现在的问题是当我的gulp watch检测到更改时,文件尚未准备好上载,因此我需要延迟gulp watch.

Currently I'm working true ftp and running gulp watch on te server, now te problem is that when my gulp watch is detecting changes the file is not ready with uploading, so I need to have a delay in my gulp watch.

gulp.task('watch', function() {
  setTimeout(function() {
    gulp.watch(config.js.app.pathIn + '/**/*.js', ['js_app']);
    gulp.watch(config.js.vendor.pathIn + '/**/*.js', ['js_vendor']);
    gulp.watch(config.scss.pathIn + '/**/*.scss', ['scss']);
  }, 3000);
});

这不会延迟文件的渲染,我如何确保在保存文件时有延迟?

This is not delaying the rendering of the files, how can I make sure to have a delay when rending the files?

推荐答案

Gulp等待看起来它可能为您工作.将其插入三个任务的顶部.

Gulp-wait looks like it could work for you. Insert it into the top of your three tasks.

gulp.task('watch', function() {
   gulp.watch(config.js.app.pathIn + '/**/*.js', setTimeout(function() {
     gulp.start('scss')
  }, 3000)
});

如果希望使用setTimeout方法,但可能以上工作,但该方法使用gulp.start-从gulp4.0中删除.如果您使用gulp4并在此处对您的任务而不是gulp.start进行函数调用,则要容易得多.

Above might work if you want a setTimeout method but it uses gulp.start - to be removed from gulp4.0. Much easier if you used gulp4 and just made a function call here to your task instead of to gulp.start.

但是我建议等一下.

这篇关于延迟吞咽手表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆