From f9cb20ffcbb1294e31c3a14e5535d4f12274b13c Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 5 Jan 2018 14:34:36 +0100 Subject: Improve annoying livereload reload behaviour for main/webview processes --- src/index.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/index.html') diff --git a/src/index.html b/src/index.html index 05a93e37b..9e5acd705 100644 --- a/src/index.html +++ b/src/index.html @@ -23,6 +23,24 @@ s.async = true; s.setAttribute('src', lrHost + '/livereload.js'); document.body.appendChild(s); + + s.onload = () => { + console.log('livereload loaded'); + const originalReloadBehaviour = window._onLiveReloadFileChanged; + + window._onLiveReloadFileChanged = (file) => { + if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) { + originalReloadBehaviour(file); + } else { + if (file.path.includes('/build/webview/')) { + console.log('Livereload: Reloading all webvies'); + const webviews = document.querySelectorAll('webview').forEach(webview => webview.reload()); + } else { + console.log('Livereload: skip reload as only main process files have changed'); + } + } + } + } })(); } -- cgit v1.2.3-54-g00ecf