Skip to content

Commit

Permalink
feat(generators/demo): do a smarter insertion of the livereload url
Browse files Browse the repository at this point in the history
This will make livereloading also work from virtualbox machines reaching out to your local machine.

Omitted when `generators/app` was changed on commit 0b10652.
  • Loading branch information
cueedee committed Oct 9, 2017
1 parent 7f6ee09 commit 335284c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion generators/demo/templates/src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,26 @@
<![endif]--><@ } @><% if ( debugging ) { %>

<link rel="stylesheet" type="text/css" href="<%- styleBase %>/debug.css?<%- buildRun %>" />
<script src="//localhost:35729/livereload.js"></script><% } %>
<script>
//
// Load `livereload` relative to document protocol and host, but on a different port.
// Just having been able to write `<script src="//:35729/livereload.js">` would have been far nicer, but that appears not to be possible.
//
// See: http://stackoverflow.com/questions/8317059/relative-path-but-for-port#answer-8317663
//

link = document.createElement( 'a' );
link.href = document.location.origin;

link.port = 35729;
link.pathname = '/livereload.js';

livereload = document.createElement( 'script' );
livereload.src = link.href

document.head.appendChild( livereload );

</script><% } %>
</head>
<body>
<div id="navigation">
Expand Down

0 comments on commit 335284c

Please sign in to comment.