Fix standalone mode: imports from js

This commit is contained in:
Joseph Garrone 2021-03-28 13:37:02 +02:00
parent 5274368f47
commit ca5b41e730
2 changed files with 20 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "keycloakify",
"version": "0.3.13",
"version": "0.3.14",
"description": "Keycloak theme generator for Reacts app",
"repository": {
"type": "git",

View File

@ -67,17 +67,28 @@ export function generateKeycloakThemeResources(
}
if (/\.js?$/i.test(filePath)) {
}
const { fixedJsCode } = replaceImportsFromStaticInJsCode({
"jsCode": sourceCode.toString("utf8"),
ftlValuesGlobalName,
"mode": params.mode
});
if (/\.js?$/i.test(filePath)) {
return { "modifiedSourceCode": Buffer.from(fixedJsCode, "utf8") };
const { fixedJsCode } = replaceImportsFromStaticInJsCode({
"jsCode": sourceCode.toString("utf8"),
ftlValuesGlobalName,
...(() => {
switch (params.mode) {
case "external assets": return {
"mode": params.mode,
"urlOrigin": params.urlOrigin,
"urlPathname": params.urlPathname
};
case "standalone": return {
"mode": params.mode
};
}
})()
});
}
return { "modifiedSourceCode": Buffer.from(fixedJsCode, "utf8") };
}