Working build

This commit is contained in:
Joseph Garrone
2024-02-12 02:00:54 +01:00
parent 91d95c7eab
commit 33bfebfa99
6 changed files with 313 additions and 342 deletions

View File

@ -1,31 +0,0 @@
import { kcContext as kcLoginThemeContext } from "./keycloak-theme/login/kcContext";
import { kcContext as kcAccountThemeContext } from "./keycloak-theme/login/kcContext";
/**
* If you need to use import.meta.env.BASE_URL, use this variable instead.
* If you can, import your assets using the import statement.
*
* See: https://docs.keycloakify.dev/importing-assets#importing-custom-assets-that-arent-fonts
*/
export const BASE_URL = (()=>{
const kcContext = (()=>{
if( kcLoginThemeContext !== undefined ){
return kcLoginThemeContext;
}
if( kcAccountThemeContext !== undefined ){
return kcLoginThemeContext
}
return undefined;
})();
return (kcContext === undefined || import.meta.env.MODE === 'development')
? import.meta.env.BASE_URL
: `${kcContext.url.resourcesPath}/build/`;
})();

View File

@ -9,7 +9,6 @@ import { useGetClassName } from "keycloakify/login/lib/useGetClassName";
import type { KcContext } from "./kcContext";
import type { I18n } from "./i18n";
import keycloakifyLogoPngUrl from "./assets/keycloakify-logo.png";
import { BASE_URL } from "../../BASE_URL";
export default function Template(props: TemplateProps<KcContext, I18n>) {
const {
@ -64,7 +63,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
This is just to show you how it can be done but this is not the best option for importing assets.
See: https://docs.keycloakify.dev/importing-assets#importing-custom-assets
*/}
<img src={`${BASE_URL}keycloakify-logo.png`} alt="Keycloakify logo" width={50} />
<img src={`${import.meta.env.BASE_URL}keycloakify-logo.png`} alt="Keycloakify logo" width={50} />
{msg("loginTitleHtml", realm.displayNameHtml)}!!!
{/* This is the preferred way to use assets */}
<img src={keycloakifyLogoPngUrl} alt="Keycloakify logo" width={50} />