Created
November 26, 2016 21:26
-
-
Save MiguelCastillo/3edea86f4b1c8303624294fdca134e5a to your computer and use it in GitHub Desktop.
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
function livereload(options) { | |
var lr = require("tiny-lr"); | |
var server = lr(); | |
var port = options || 35729; | |
server.listen(port, function(err) { | |
console.log("livereload server started"); | |
}); | |
function bundleVisitor(cb) { | |
return function getBundleNames(bundle) { | |
if (bundle) { | |
cb(bundle); | |
} | |
return bundle; | |
}; | |
} | |
return { | |
postbundle: function(bundler, context) { | |
var bundleDest = []; | |
context.visitBundles(bundleVisitor(function(bundle) { | |
bundleDest.push(bundle.dest); | |
})); | |
if (bundleDest.length) { | |
server.changed({ | |
body: { | |
files: bundleDest | |
} | |
}); | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment