gulp.run 已弃用.如何编写任务? [英] gulp.run is deprecated. How do I compose tasks?

查看:18
本文介绍了gulp.run 已弃用.如何编写任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个组合任务,我不知道如何用任务依赖项替换它.

Here is a composed task I don't know how to replace it with task dependencies.

...
gulp.task('watch', function () {
 var server = function(){
  gulp.run('jasmine');
  gulp.run('embed');
 };
 var client = function(){
  gulp.run('scripts');
  gulp.run('styles');
  gulp.run('copy');
  gulp.run('lint');
 };
 gulp.watch('app/*.js', server);
 gulp.watch('spec/nodejs/*.js', server);
 gulp.watch('app/backend/*.js', server);
 gulp.watch('src/admin/*.js', client);
 gulp.watch('src/admin/*.css', client);
 gulp.watch('src/geojson-index.json', function(){
  gulp.run('copygeojson');
 });
});

对应的变更日志https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#35 [弃用 gulp.run]

The corresponding changelog https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#35 [deprecate gulp.run]

推荐答案

gulp.task('watch', function () {
  var server = ['jasmine', 'embed'];
  var client = ['scripts', 'styles', 'copy', 'lint'];
  gulp.watch('app/*.js', server);
  gulp.watch('spec/nodejs/*.js', server);
  gulp.watch('app/backend/*.js', server);
  gulp.watch('src/admin/*.js', client);
  gulp.watch('src/admin/*.css', client);
  gulp.watch('src/geojson-index.json', ['copygeojson']);
});

您不再需要传递函数(尽管您仍然可以)来运行任务.你可以给 watch 一个任务名称数组,它会为你做这件事.

You no longer need to pass a function (though you still can) to run tasks. You can give watch an array of task names and it will do this for you.

这篇关于gulp.run 已弃用.如何编写任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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