Last active
November 11, 2015 04:45
-
-
Save zertosh/a53adf08342e772ceccc to your computer and use it in GitHub Desktop.
watchify-label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = require('./other'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = 'other'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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