說我有一個看起來像這樣一個任務:如何將參數傳遞給Gulp任務?
settings.localLESS = ["../css/*.less"];
gulp.task('compile-less-files', function(){
gulp.src(settings.localLESS)
.pipe(less())
.pipe(minifyCSS())
.pipe(gulp.dest(someDest));
})
gulp.watch(settings.localLESS, ['compile-less-files']).on('change', function(event) {
...
});
但我不想編譯它們。我只想編譯我作爲參數傳遞給該任務的文件。也許這樣?
gulp.task('compile-less-file', function(fileName){
gulp.src(fileName)
.pipe(less())
.pipe(minifyCSS())
.pipe(gulp.dest(someDest));
})
gulp.watch(settings.localLESS, ['compile-less-file']).on('change', function(event) {
...
});
更新:我想成立觀察家所有源項目文件和任何一次文件將改爲運行特定的任務。