keycloakify-custom/src/PUBLIC_URL.ts

31 lines
893 B
TypeScript
Raw Normal View History

2024-01-11 14:06:43 +00:00
import { kcContext as kcLoginThemeContext } from "keycloak-theme/login/kcContext";
import { kcContext as kcAccountThemeContext } from "keycloak-theme/login/kcContext";
/**
* If you need to use process.env.PUBLIC_URL, use this variable instead.
* If you can, import your assets using the import statement.
*
2024-01-11 14:21:53 +00:00
* See: https://docs.keycloakify.dev/importing-assets#importing-custom-assets-that-arent-fonts
2024-01-11 14:06:43 +00:00
*/
export const PUBLIC_URL = (()=>{
const kcContext = (()=>{
if( kcLoginThemeContext !== undefined ){
return kcLoginThemeContext;
}
if( kcAccountThemeContext !== undefined ){
return kcLoginThemeContext
}
return undefined;
})();
return (kcContext === undefined || process.env.NODE_ENV === "development")
? process.env.PUBLIC_URL
: `${kcContext.url.resourcesPath}/build`;
})();