0

我有大约六个与此类似的 Gulp 任务:

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 允许多个任务,对吧?为什么只执行文件中的最后一个任务?

4

1 回答 1

1

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

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

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

您可以在文档中阅读有关任务依赖项的更多信息

于 2015-09-24T11:42:50.177 回答