-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2164 from alphagov/2091-get-live-reloading-workin…
…g-within-the-error-screen Get live reloading working with the error screen
- Loading branch information
Showing
14 changed files
with
133 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
<script src="{{scriptConfig.src}}"></script> | ||
{% endif %} | ||
{% endfor %} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// dependencies | ||
const EventEmitter = require('events') | ||
|
||
// npm dependencies | ||
const browserSync = require('browser-sync') | ||
|
||
const eventEmitter = new EventEmitter() | ||
|
||
const pageLoadedEvent = 'sync-changes:page-loaded' | ||
|
||
function pageLoaded () { | ||
eventEmitter.emit(pageLoadedEvent) | ||
return { status: 'received ok' } | ||
} | ||
|
||
function sync ({ port, proxyPort, files }) { | ||
browserSync({ | ||
ws: true, | ||
proxy: 'localhost:' + proxyPort, | ||
port, | ||
ui: false, | ||
files, | ||
ghostMode: false, | ||
open: false, | ||
notify: false, | ||
logLevel: 'error', | ||
callbacks: { | ||
ready: (_, bs) => { | ||
// Repeat browser sync reload every 1000 milliseconds until it is successful | ||
const intervalId = setInterval(browserSync.reload, 1000) | ||
eventEmitter.once(pageLoadedEvent, () => { | ||
bs.events.once('browser:reload', () => { | ||
clearInterval(intervalId) | ||
}) | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
module.exports = { | ||
sync, | ||
pageLoaded | ||
} |
This file contains 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
This file contains 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