Skip to content

Instantly share code, notes, and snippets.

@newvertex
Created September 15, 2016 14:14
Show Gist options
  • Save newvertex/f7d9768304addccd066e09687f8558fc to your computer and use it in GitHub Desktop.
Save newvertex/f7d9768304addccd066e09687f8558fc to your computer and use it in GitHub Desktop.
Add Live Reload to all html with our Http-Server on this url : https://github.com/newvertex/SimpleHttpServer
var liveReloadUrl = "http://localhost:35729/livereload.js";
var liveReloadTag = '<script type="text/javascript" src="' + liveReloadUrl + '"></script>"';
if(!String.prototype.insertAt){
String.prototype.insertAt = function(index = 0, string = '') {
if(index>0)
return this.substring(0, index) + string + this.substring(index, this.length);
else
return this + string;
};
}
function addTag(data, tag = liveReloadTag) {
if (path.extname(url) == '.html') {
data = data.insertAt(data.lastIndexOf('</body>'),tag);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment