unleash-server
Version:
Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.
27 lines • 1.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadIndexHTML = void 0;
const fs_1 = __importDefault(require("fs"));
const rewriteHTML_1 = require("./rewriteHTML");
const path_1 = __importDefault(require("path"));
const make_fetch_happen_1 = __importDefault(require("make-fetch-happen"));
async function loadIndexHTML(config, publicFolder) {
const { cdnPrefix, baseUriPath = '' } = config.server;
const uiFlags = JSON.stringify(config.ui.flags);
let indexHTML;
if (cdnPrefix) {
const res = await (0, make_fetch_happen_1.default)(`${cdnPrefix}/index.html`);
indexHTML = await res.text();
}
else {
indexHTML = fs_1.default
.readFileSync(path_1.default.join(publicFolder, 'index.html'))
.toString();
}
return (0, rewriteHTML_1.rewriteHTML)(indexHTML, baseUriPath, cdnPrefix, uiFlags);
}
exports.loadIndexHTML = loadIndexHTML;
//# sourceMappingURL=load-index-html.js.map