node package manager

@alexistessier/gulp-workflow-common-task

@alexistessier/gulp-workflow-common-task

version npm version

Dependencies Status devDependencies Status

Home Page

A set of common gulp task I use

Purpose

Reuse some gulp tasks through projects

Install

npm install @alexistessier/gulp-workflow-common-task

How to use

var path = require('path');
 
var task = require('@alexistessier/gulp-workflow-common-task');
 
//Set a task named babel-es6-for-node 
//Set a babel task, with the "es6-for-node" preset 
task.babel('es6-for-node');
 
//Set a task named mustache-readme-for-node-package 
//Set a mustache task, with the "readme-for-node-package" preset and custom params 
task.mustache('readme-for-node-package', {
    'view.myCustomData': 'Hello world'
});
 
//Then the build and watch tasks can be defined like that 
task.build();
task.watch();
 
task.default('build');

Common tasks list

task.babel
gulp.task('babel', function (done) {
    gulp.src(params.src)
        .pipe(plumber())
        .pipe(sourcemaps.init())
        .pipe(babel(params.options))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(params.dest))
 
        .on('end', function() {
            done();
        });
});

Available presets

  • es6-for-node (default)

    aram type description or default value
    rc object [path.join(process.cwd(), "sources/**/*.js")]
    ptions object {"presets":["babel-preset-es2015"]}
    est string "build/"
task.moduleBuild
params.options.rollup.plugins = _.isArray(params.options.rollup.plugins) ? params.options.rollup.plugins : [];
params.options.rollup.plugins.unshift(commonjs(params.options.commonjs));
params.options.rollup.plugins.unshift(nodeResolve(params.options.nodeResolve));
params.options.rollup.plugins.unshift(rollupFlow(params.options.flow));
 
gulp.task('moduleBuild', function (done) {
    var stream = rollup(_.assign({}, {
            entry: params.entry,
            sourceMap: true
        }, params.options.rollup))
        .pipe(source(path.basename(params.entry), path.dirname(params.entry)))
        .pipe(buffer())
        .pipe(plumber());
 
        if(params.sourcemaps === true){
            stream = stream.pipe(sourcemaps.init({loadMaps: true}));
        }
 
        if(params.babel === true){
            stream = stream.pipe(babel(params.options.babel))
        }
 
        if(params.uglify === true){
            stream = stream.pipe(uglify(params.options.uglify));
        }
        
        stream = stream.pipe(rename(params.outputName));
 
        if(params.sourcemaps === true){
            stream = stream.pipe(sourcemaps.write('.'));
        }
 
        stream = stream.pipe(gulp.dest(params.dest))
        .on('end', function() {
            done();
        });
});

Available presets

  • flowtype-rollup-es6-uglify (default)

    aram type description or default value
    ntry object path.join(process.cwd(), "sources/index.js")
    rc object [path.join(process.cwd(), "sources/**/*.js")]
    utputName string "bundle.js"
    ourcemaps boolean true
    abel boolean true
    glify boolean true
    ptions object {"commonjs":{"include":"node_modules/**","exclude":[],"extensions":[".js"],"namedExports":{}},"rollup":{"format":"umd","moduleId":"gulp-workflow-common-task","moduleName":"GulpWorkflowCommonTask","indent":false},"nodeResolve":{"module":true,"jsnext":true,"main":true,"skip":[],"extensions":[".js",".json"],"preferBuiltins":true,"browser":true},"flow":{"all":false,"pretty":false},"uglify":{},"babel":{"presets":["es2015"]}}
    est string "build/"
task.mustache
gulp.task('mustache', function(done) {
    gulp.src(params.src)
        .pipe(plumber())
        .pipe(mustache(params.view))
        .pipe(rename(function (path) {
            path.basename = path.basename.replace(params.destExt, '');
            path.extname = params.destExt;
        }))
        .pipe(gulp.dest(params.dest))
        .on('end', function() {
            done();
        });
});

Available presets

  • readme-for-node-package

    aram type description or default value
    rc object [path.join(process.cwd(), "README.mustache")]
    iew object Some computed values: package,furyiopath,username
    estExt string ".md"
    est string "./"
task.documentation
gulp.task('documentation', function(done) {
    gulp.src(params.src, {read: false})
        .pipe(plumber())
        .pipe(gulpDocumentation('html', params.options, params.information))
        .pipe(gulp.dest(params.dest))
        .on('end', done)
});

Available presets

  • html (default)

    aram type description or default value
    rc object [path.join(process.cwd(), "sources/**/*.js")]
    ptions object {"polyglot":false}
    nformation object {"name":"gulp-workflow-common-task","version":"2.11.0"}
    est string "documentation"