GulpJS 中的多任务

Multitask in GulpJS

你们好吗?

如何在 GulpJS 中创建类似于在 GruntJS 中创建的任务? 可以吗?

示例:

module.exports = function(grunt) {
    "use strict"

    grunt.initConfig({

        uglify: {
            options: {
                manage: false
            },
            dev: {...},
            prod: {...}
        },

        less: {
            options: {
                cleancss: true
            },
            dev: {...},
            prod: {...}
        }

    });

    grunt.registerTask("dev", ["uglify:dev", "less:dev"]);
    grunt.registerTask("prod", ["less:prod", "less:prod"]);
}

谢谢!

我相信您正在寻找的是如何 运行 完成一系列任务。以下是您将如何做到这一点:

var gulp = require('gulp');

// takes in a callback so the engine knows when it'll be done
gulp.task('one', function(cb) {
    // do stuff -- async or otherwise
    cb(err); // if err is not null and not undefined, the orchestration will stop, and 'two' will not run
});

// identifies a dependent task must be complete before this one begins
gulp.task('two', ['one'], function() {
    // task 'one' is done now
});

gulp.task('default', ['one', 'two']);
// alternatively: gulp.task('default', ['two']);

您可以在此处阅读更多相关信息:https://github.com/gulpjs/gulp/blob/master/docs/recipes/running-tasks-in-series.md