gulp.run is deprecated. How do I compose tasks?(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 已弃用.如何编写任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:gulp.run 已弃用.如何编写任务?


- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01