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