Skip to content

Instantly share code, notes, and snippets.

@zertosh
Last active November 11, 2015 04:45
Show Gist options
  • Save zertosh/a53adf08342e772ceccc to your computer and use it in GitHub Desktop.
Save zertosh/a53adf08342e772ceccc to your computer and use it in GitHub Desktop.
watchify-label
/node_modules
var browserify = require('browserify');
var through = require('through2');
var watchify = require('watchify');
var b = browserify({
entries: [ __dirname + '/index.js' ],
cache: {}, packageCache: {}
});
b.plugin(watchify);
b.on('update', function() {
bundle();
});
b.on('reset', function() {
labeler();
});
labeler();
bundle();
function labeler() {
b.pipeline.get('label').unshift(through.obj(function(row, enc, next) {
console.log('label: %j', row.file);
next(null, row);
}));
}
function bundle() {
b.bundle(function(err, src) {
if (err) throw err;
console.log('b.bundle() ended - %s bytes', src.length);
});
}
module.exports = require('./other');
module.exports = 'other';
{
"name": "watchify-label",
"version": "0.0.0",
"scripts": {
"start": "node build.js"
},
"dependencies": {
"browserify": "^12.0.1",
"through2": "^2.0.0",
"watchify": "^3.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment