UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

21 lines 785 B
import fs from 'fs'; import { rewriteHTML } from './rewriteHTML.js'; import path from 'path'; import ky from 'ky'; export async function loadIndexHTML(config, publicFolder) { const { cdnPrefix, baseUriPath = '' } = config.server; const uiFlags = encodeURI(JSON.stringify(config.ui.flags || '{}')); const unleashToken = config.unleashFrontendToken; let indexHTML; if (cdnPrefix) { const res = await ky.get(`${cdnPrefix}/index.html`); indexHTML = await res.text(); } else { indexHTML = fs .readFileSync(path.join(config.publicFolder || publicFolder, 'index.html')) .toString(); } return rewriteHTML(indexHTML, baseUriPath, cdnPrefix, uiFlags, unleashToken); } //# sourceMappingURL=load-index-html.js.map