1import qs from 'qs'; 2 3const getDevServer = () => { 4 // Disable for SSR 5 if (typeof window === 'undefined') { 6 return { 7 bundleLoadedFromServer: true, 8 fullBundleUrl: '', 9 url: '', 10 }; 11 } 12 13 return { 14 // The bundle is always loaded from a server in the browser. 15 bundleLoadedFromServer: true, 16 17 /** URL but ensures that platform query param is added. */ 18 get fullBundleUrl() { 19 if (document?.currentScript && 'src' in document.currentScript) { 20 return document.currentScript.src; 21 } 22 23 const url = window.location.toString(); 24 const query = qs.parse(url); 25 26 return ( 27 location.origin + location.pathname + '?' + qs.stringify({ ...query, platform: 'web' }) 28 ); 29 }, 30 url: location.origin + location.pathname, 31 }; 32}; 33 34export default getDevServer; 35