2.11.0 • Published 8 years ago

@alexistessier/gulp-workflow-common-task v2.11.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

@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())
		.pipe(sourcemaps.init({loadMaps: true}))
		.pipe(babel(params.options.babel))

		if(params.uglify === true){
			stream = stream.pipe(uglify(params.options.uglify));
		}
		
		stream.pipe(rename(params.outputName))
		.pipe(sourcemaps.write('.'))
		.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"
    	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.10.0"}
    	dest|string|"documentation"
2.11.0

8 years ago

2.10.0

8 years ago

2.9.0

8 years ago

2.8.0

8 years ago

2.7.0

8 years ago

2.6.0

8 years ago

2.5.1

8 years ago

2.5.0

8 years ago

2.4.1

8 years ago

2.4.0

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.4

8 years ago

2.1.3

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago