From 3c2db2bc9166514d62a5bbf9d37e8c50ab19b4f3 Mon Sep 17 00:00:00 2001 From: Tom Fuertes Date: Fri, 16 Jan 2015 23:34:24 -0600 Subject: [PATCH 1/2] liveReload via script (no browser ext) --- lib/proxy-injector.js | 9 +++++++++ server.js | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/proxy-injector.js b/lib/proxy-injector.js index 4e4de1f..116b242 100644 --- a/lib/proxy-injector.js +++ b/lib/proxy-injector.js @@ -37,6 +37,7 @@ var createProxyServer = function(config) { processHtmlData(res) .then(function(htmlData) { var html = injectFiles(htmlData, _targetFiles); + html = injectLiveReload(html); clientRes.end(html); }, logErrorAndExit); }; @@ -110,6 +111,14 @@ var injectFiles = function(htmlData, files) { return $.html(); }; +var injectLiveReload = function (html) { + return html.replace('', + "" + ); +}; + var appendFile = function(node, tag) { return function(file) { var data = fs.readFileSync(file, 'utf8'); diff --git a/server.js b/server.js index 0e239af..8fede0c 100644 --- a/server.js +++ b/server.js @@ -45,7 +45,6 @@ console.log("Proxy server listening on port", options.proxyPort); // Live reload server watching for files in target directory var livereloadServer = livereload.createServer({ - originalPath: 'http://localhost:' + options.proxyPort, applyCSSLive: false -}); +}); // default port livereloadServer.watch(options.targetDir); From 3061a597ac95ef99cebdf580b4e22e9f2f1a69de Mon Sep 17 00:00:00 2001 From: Tom Fuertes Date: Fri, 16 Jan 2015 23:41:55 -0600 Subject: [PATCH 2/2] close loop w/ docs! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b2c8e0..ad3f72c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # node-proxy-injector - A script that allows you to proxy a remote server and inject css stylesheets and js scripts into the remote server response. The tool supports live reload, but you must have browser extensions installed and configured. For details visit http://help.livereload.com/kb/general-use/browser-extensions. + A script that allows you to proxy a remote server and inject css stylesheets and js scripts into the remote server response. The tool supports live reload. Note that this tool is a work in progress!