-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use process.env.EMBER_CLI_INJECT_LIVE_RELOAD_HOST #5
Conversation
@@ -7,7 +7,9 @@ module.exports = { | |||
var liveReloadPort = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_PORT; | |||
|
|||
if (liveReloadPort && type === 'head') { | |||
return '<script src="http://localhost:' + liveReloadPort + '/livereload.js?snipver=1" type="text/javascript"></script>'; | |||
var liveReloadHost = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_HOST || '//localhost'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need the //
either way?
Updated PR. Hopefully this will do it |
I don't have much experience with node but wouldn't it be more convenient to somehow get the hostname from request's headers? |
This file is rebuilt once for all clients, not for a single one. It is likely that some trickery could do exactly what you are suggesting, but it isn't obvious. |
@@ -7,7 +7,9 @@ module.exports = { | |||
var liveReloadPort = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_PORT; | |||
|
|||
if (liveReloadPort && type === 'head') { | |||
return '<script src="http://localhost:' + liveReloadPort + '/livereload.js?snipver=1" type="text/javascript"></script>'; | |||
var liveReloadHost = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_HOST || 'localhost'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stylistically, i'd put this after the var liveReloadPort
in line 7.
I noticed something wrong about this "fix" so please do not merge yet. I have three apps, all ember-cli 0.1.1 |
Any updates on this one? If this dosen't work I'd propose the following dynamic alternative: function contentFor(type) {
var liveReloadPort = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_PORT;
var liveReloadHost = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_HOST;
if (liveReloadPort && type === 'head') {
if (liveReloadHost) {
return '<script src="//'+ liveReloadHost +':' + liveReloadPort + '/livereload.js?snipver=1" type="text/javascript"></script>';
} else {
return '<script type="text/javascript">(function(d,l,p,s){s=d.createElement("script");s.type="text/javascript";s.async=true;s.src=l.protocol+"//"+l.hostname+":"+p+"/livereload.js?snipver=1";d.getElementsByTagName("head")[0].appendChild(s)})(document,document.location,' + liveReloadPort + ')</script>';
}
}
} If there is no <script type="text/javascript">
(function(d, l, p, s) {
s = d.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = l.protocol + "//"
+ l.hostname + ":"
+ p
+ "/livereload.js?snipver=1";
d.getElementsByTagName("head")[0].appendChild(s);
})(document, document.location, 12345);
</script> This script takes the current hostname of the page, which is most likely the livereload host as well. At least this makes way more sense than defaulting to |
Make use of environmental variable EMBER_CLI_INJECT_LIVE_RELOAD_HOST if available
Started here: https://github.com/rwjblue/ember-cli-inject-live-reload/pull/4#issuecomment-57911657