exit gulp when build is finished

一个人想着一个人 提交于 2019-12-12 05:28:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!