本文介紹了gulp.run 已棄用.如何編寫(xiě)任務(wù)?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
這是一個(gè)組合任務(wù),我不知道如何用任務(wù)依賴項(xiàng)替換它.
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');
});
});
對(duì)應(yīng)的變更日志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']);
});
您不再需要傳遞函數(shù)(盡管您仍然可以)來(lái)運(yùn)行任務(wù).你可以給 watch 一個(gè)任務(wù)名稱數(shù)組,它會(huì)為你做這件事.
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.
這篇關(guān)于gulp.run 已棄用.如何編寫(xiě)任務(wù)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!