Export polyfill of process.env.PUBLIC_URL
This commit is contained in:
parent
1f79a8f7dc
commit
217439d673
13
src/PUBLIC_URL.ts
Normal file
13
src/PUBLIC_URL.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir } from "keycloakify/bin/constants";
|
||||
|
||||
/**
|
||||
* This is an equivalent of process.env.PUBLIC_URL thay you can use in Webpack projects.
|
||||
* This works both in your main app and in your Keycloak theme.
|
||||
*/
|
||||
export const PUBLIC_URL = (() => {
|
||||
const kcContext = (window as any)[nameOfTheGlobal];
|
||||
|
||||
return kcContext === undefined || process.env.NODE_ENV === "development"
|
||||
? process.env.PUBLIC_URL
|
||||
: `${kcContext.url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}`;
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user