gulp-browserify-thin
A very thin extension of Browserify that causes the .bundle() method to return a vinyl file instead of a stream.
Last updated 6 years ago by bluejeansandrain .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-browserify-thin 
SYNC missed versions from official npm registry.

gulp-browserify-thin

A very thin extension of Browserify that overrides the bundle() method to return a vinyl file object stream instead of the original node readable stream.

Until you call bundle(), you are working with a plain old browserify instance. See Browserify's documentation for option and method documentation.

Installation

$ npm install gulp-browserify-thin --save-dev

Usage

In your gulpfile...

var gulp = require('gulp');
var browserify = require('gulp-browserify-thin');

gulp.task('default', function()
{
	// This part is just like using vanilla Browserify.
	var b = browserify(/* files=[] or opts={} */)
		.add(file, opts)
		.require(file, opts)
		.external(file)
		.ignore(file)
		.exclude(file)
		.transform(opts, tr)
		.plugin(plugin, opts)
		// ... and so on, calling browserify methods any way you want.
		;

	// The bundle method is the only one that's different from vanilla
	// Browserify. It takes a filename instead of an optional callback.
	// The filename does not need to exist. It's "fake" so that downstream gulp
	// plugins that expect a filename will still work. It will also be your
	// output filename if you pipe to gulp.dest().
	var stream = b.bundle('output.file.name.js')

	// You now have a through object stream that will have a vinyl file
	// pushed into it. The vinyl file contains the filename and the readable
	// stream that Browserify outputs. This is what gulp plugins are
	// expected to return so you can now do your gulp thing!

	stream
		// errors emitted by the original Browserify bundle method are
		// re-emitted on the through stream so that they can be handled in your
		// gulp file.
		.on('error', function(err)
		{
			console.error(err.toString());

			// If you want to abort the gulp run then you'll need to exit.
			process.exit(1);
		})
		.pipe(/* some other gulp plugin that handles streamed sources */)
		.pipe(gulp.dest('./out'));

	// Remember to return the stream when you're done so that any dependant
	// tasks know not to start until this task is done.
	return stream;
});

Current Tags

  • 0.1.5                                ...           latest (6 years ago)

6 Versions

  • 0.1.5                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 5
Last Day 1
Last Week 1
Last Month 3
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |