Created
September 15, 2016 14:14
-
-
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
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 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