Skip to content

Instantly share code, notes, and snippets.

@IbnSaeed
Forked from shakyShane/example.js
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IbnSaeed/b7874cfa98325ab3861e to your computer and use it in GitHub Desktop.
Save IbnSaeed/b7874cfa98325ab3861e to your computer and use it in GitHub Desktop.
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