2015-09-24 32 views
0

我有类似这种大约六咕嘟咕嘟任务:Gulp只执行gulpfile中的最后一项任务?

gulp.task('scripts', function() { 
    return gulp.src([ 
     'public_html/assets/plugins/zeroclipboard/ZeroClipboard.min.js', 
     'public_html/assets/plugins/redactor/redactor.min.js', 
     'public_html/assets/libraries/autobahn.min.js' 
    ]) 
     .pipe(concat('localStatic.js')) 
     .pipe(gulp.dest('public_html/assets/dist/js/')) 
     .pipe(rename('localStatic.min.js')) 
     .pipe(uglify()) 
     .pipe(gulp.dest('public_html/assets/dist/js')); 
}); 

当我运行在终端gulp,只执行最后一项任务(或者至少,仅生成从最后一个任务的JS文件)。

Gulp允许多项任务,对不对?为什么只执行文件中的最后一项任务?

+0

任务依赖你在您列出所有你的任务,你要为默认以“吞掉”运行gulpfile.js的底部有你一口“默认”任务命令?例如: gulp.task('default',['styles','scripts','images']); – givehug

回答

1

您可以同时运行多个任务是,只要它们具有不同的名称。

gulp.task('name', function() {}) 
gulp.task('of', function() {}) 
// ... task definitions 
gulp.task('default', ['name', 'of', 'the', 'tasks', 'you', 'want', 'to','run']); 

这将运行gulp命令时并行指定的所有任务。

你可以阅读更多有关docs

+0

我刚才意识到任务需要有唯一的名字。我有所有名为'scripts'的任务,显然只有最后一个被执行。 – Nate

+1

哦,是的,你不能这样做:) – kombucha