Skip to content

Commit

Permalink
Places the set/getLibs functions in script.js and removes utils depen…
Browse files Browse the repository at this point in the history
…dency. Leaves utils.js as other code in our repo calls getLibs
  • Loading branch information
JasonHowellSlavin committed Jun 19, 2024
1 parent 0303383 commit 726f3da
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { setLibs } from './utils.js';

const LIBS = '/libs';
const STYLES = ['/styles/styles.css'];
const CONFIG = {
Expand Down Expand Up @@ -157,6 +155,22 @@ const loadStyle = (path) => {
eagerLoad(marquee.querySelector('img'));
}());

export const [setLibs, getLibs] = (() => {
let libs;
return [
(prodLibs, location) => {
libs = (() => {
const { hostname, search } = location || window.location;
if (!(hostname.includes('.hlx.') || hostname.includes('local'))) return prodLibs;
const branch = new URLSearchParams(search).get('milolibs') || 'main';
if (branch === 'local') return 'http://localhost:6456/libs';
return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`;
})();
return libs;
}, () => libs,
];
})();

const miloLibs = setLibs(LIBS);

(function loadStyles() {
Expand Down

0 comments on commit 726f3da

Please sign in to comment.