Skip to content

Commit

Permalink
add 'liveReloadBaseHost' option
Browse files Browse the repository at this point in the history
In case your index.html is being served on a different domain
(i.e. your rails app that fetches it from redis)
the request for `ember-cli-live-reload.js` has to be triggered
towards the ember-cli host.

i.e.
if your rails app runs on `http://localhost:3000` the live reload
script should be requested at `http://localhost:4200/ember-cli-live-reload.js`.

The current config options do not seem to allow this setup
thanks to ember-cli/ember-cli#4283 it is
possible to set the `host` for the liveReload server but this does
not eliminate the need to fetch `ember-cli-live-reload.js` from the
ember-cli server itself.

This change aims to solve this missing use case by appending the
`baseHost` to the script path
  • Loading branch information
ghedamat committed Oct 16, 2015
1 parent d354e9c commit 10f19d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ module.exports = {
contentFor: function(type) {
var liveReloadPort = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_PORT;
var baseURL = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_BASEURL;
var host = process.env.EMBER_CLI_INJECT_LIVE_RELOAD_BASEHOST + baseURL;

if (liveReloadPort && type === 'head') {
return '<script src="' + baseURL + 'ember-cli-live-reload.js" type="text/javascript"></script>';
return '<script src="' + host + 'ember-cli-live-reload.js" type="text/javascript"></script>';
}
},

Expand All @@ -31,7 +32,10 @@ module.exports = {

if (options.liveReload !== true) { return; }

options.liveReloadBaseHost = options.liveReloadBaseHost || '';

process.env.EMBER_CLI_INJECT_LIVE_RELOAD_PORT = options.liveReloadPort;
process.env.EMBER_CLI_INJECT_LIVE_RELOAD_BASEHOST = options.liveReloadBaseHost;
process.env.EMBER_CLI_INJECT_LIVE_RELOAD_BASEURL = options.baseURL; // default is '/'

app.use(options.baseURL + 'ember-cli-live-reload.js', function(request, response, next) {
Expand Down

0 comments on commit 10f19d5

Please sign in to comment.