@alexistessier/gulp-workflow-common-task

2.11.0 • Public • Published

@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)

    param type description or default value
    src object [path.join(process.cwd(), "sources/**/*.js")]
    options object {"presets":["babel-preset-es2015"]}
    dest 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)

    param type description or default value
    entry object path.join(process.cwd(), "sources/index.js")
    src object [path.join(process.cwd(), "sources/**/*.js")]
    outputName string "bundle.js"
    sourcemaps boolean true
    babel boolean true
    uglify boolean true
    options 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"]}}
    dest 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

    param type description or default value
    src object [path.join(process.cwd(), "README.mustache")]
    view object Some computed values: package,furyiopath,username
    destExt string ".md"
    dest 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)

    param type description or default value
    src object [path.join(process.cwd(), "sources/**/*.js")]
    options object {"polyglot":false}
    information object {"name":"gulp-workflow-common-task","version":"2.11.0"}
    dest string "documentation"

Readme

Keywords

Package Sidebar

Install

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

Weekly Downloads

29

Version

2.11.0

License

MIT

Last publish

Collaborators

  • alexistessier