diff --git a/dev/client.js b/dev/client.js index 2732049..af57961 100644 --- a/dev/client.js +++ b/dev/client.js @@ -1,35 +1,37 @@ /* eslint-disable no-console */ -const socket = new WebSocket( - `${(location.protocol === 'http:' ? 'ws://' : 'wss://') + location.host}/`, -); +if (!navigator.webdriver) { + const socket = new WebSocket( + `${(location.protocol === 'http:' ? 'ws://' : 'wss://') + location.host}/`, + ); -socket.addEventListener('message', (message) => { - if (!message.data) return; + socket.addEventListener('message', (message) => { + if (!message.data) return; - const data = JSON.parse(message.data); + const data = JSON.parse(message.data); - let reload = true; + let reload = true; - // hot reload stylesheets - document.querySelectorAll('link[rel=stylesheet]').forEach((el) => { - if (el.getAttribute('href') === data.url) { - el.setAttribute('href', data.url); - reload = false; - } + // hot reload stylesheets + document.querySelectorAll('link[rel=stylesheet]').forEach((el) => { + if (el.getAttribute('href') === data.url) { + el.setAttribute('href', data.url); + reload = false; + } + }); + + // hot reload images + document.querySelectorAll('img').forEach((el) => { + if (el.getAttribute('src') === data.url) { + el.setAttribute('src', data.url); + reload = false; + } + }); + + // otherwise, reload page + if (reload) location.reload(); }); - // hot reload images - document.querySelectorAll('img').forEach((el) => { - if (el.getAttribute('src') === data.url) { - el.setAttribute('src', data.url); - reload = false; - } + socket.addEventListener('close', () => { + console.warn('Development server disconnected'); }); - - // otherwise, reload page - if (reload) location.reload(); -}); - -socket.addEventListener('close', () => { - console.warn('Development server disconnected'); -}); +}