构建完成后退出gulp [英] exit gulp when build is finished
问题描述
我正在使用gulp来缩小CSS和JS文件.
I'm using gulp to minify CSS and JS files.
当我从终端运行gulp命令gulp build:website1:desktop
时,它成功完成,但没有返回到shell提示符,我必须运行Ctrl+C
以返回到命令提示符
When I run the gulp command gulp build:website1:desktop
from a terminal, it finishes successfully but it does not return to the shell prompt, I have to run Ctrl+C
to return to the command prompt
这是我正在使用的
gulp.task('build:website1:desktop', function () {
runSequence(
'website1:desktop:scripts',
'website1:desktop:css');
})
任何想法如何在不每次都键入Ctrl+C
的情况下退出并返回命令提示符?
Any ideas How to exit and return to the command prompt without typing Ctrl+C
every time?
谢谢.
推荐答案
第一件事是确保您的scripts
和css
任务返回流或诺言,以便runSequence
知道何时执行这些任务完成的.对于大多数gulp任务,将return语句与gulp.src(…)
一起使用即可做到:
First thing is to make sure that your scripts
and css
tasks return a stream or a promise, so that runSequence
knows when these tasks are finished. For most gulp tasks, using the return statement with gulp.src(…)
will do just that:
gulp.task('website1:desktop:scripts', function() {
return gulp.src(…)
.pipe(doSomething())
.pipe(gulp.dest(…));
});
接下来的事情是为runSequence
提供回调:
Next thing is to provide a callback for runSequence
:
gulp.task('build:website1:desktop', function (callback) {
runSequence(
'website1:desktop:scripts',
'website1:desktop:css',
callback);
});
这应该可以解决问题.
这篇关于构建完成后退出gulp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!