Skip to content

Instantly share code, notes, and snippets.

@shakyShane
Created October 24, 2014 14:12
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shakyShane/3d5ec6685e07fd3227ba to your computer and use it in GitHub Desktop.
Save shakyShane/3d5ec6685e07fd3227ba to your computer and use it in GitHub Desktop.
Reloader plugin
var browserSync = require("browser-sync");
browserSync.use({
plugin: function () { /* noop */},
hooks: {
'client:js': require("fs").readFileSync("./reloader.js", "utf-8") // Link to your file
}
});
browserSync({
server: "./app",
files: [
"css/*.css",
],
open: false
});
/**
* Reload plugin example
*/
(function ($window, $document, bs) {
var socket = bs.socket;
var canReload = false;
socket.on("connection", function (client) {
if (canReload) {
canReload = false;
window.location.reload();
}
});
socket.on("disconnect", function (client) {
canReload = true;
});
})(window, document, ___browserSync___);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment