Created
October 24, 2014 14:12
-
-
Save shakyShane/3d5ec6685e07fd3227ba to your computer and use it in GitHub Desktop.
Reloader plugin
This file contains hidden or 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 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 | |
}); |
This file contains hidden or 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
/** | |
* 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