问题
I'm using gulp to minify CSS and JS files.
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
Here is a what I'm using
gulp.task('build:website1:desktop', function () {
runSequence(
'website1:desktop:scripts',
'website1:desktop:css');
})
Any ideas How to exit and return to the command prompt without typing Ctrl+C
every time?
Thank you in advance.
回答1:
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(…));
});
Next thing is to provide a callback for runSequence
:
gulp.task('build:website1:desktop', function (callback) {
runSequence(
'website1:desktop:scripts',
'website1:desktop:css',
callback);
});
This should do the trick.
来源:https://stackoverflow.com/questions/43794077/exit-gulp-when-build-is-finished