Files
authentik/web/bundler/utils/node.js
Teffen Ellis 17da90df6c web: Fix docs links, a11y input descriptors (#16671)
* web: Clarify required marker when using screen reader.

* web: Mark helper text as input descriptor.

* web: Use next domain when in development.

* web: Clean up constants. Fix attribute mapping.

* web: use previous function name.

* web: Fix sort.

* web: Use constant.

* web: Use prefix.

* web: keep using current release for notes.
2025-09-18 00:34:15 +00:00

39 lines
1.1 KiB
JavaScript

/**
* @file Bundler utilities.
*/
import { NodeEnvironment, serializeEnvironmentVars } from "@goauthentik/core/environment/node";
import {
AuthentikVersion,
CurrentReleaseDocsURL,
PreReleaseDocsURL,
ReleaseNotesURL,
} from "@goauthentik/core/version/node";
/**
* Creates a mapping of environment variables to their respective runtime constants.
*/
export function createBundleDefinitions() {
const SerializedNodeEnvironment = /** @type {`"development"` | `"production"`} */ (
JSON.stringify(NodeEnvironment)
);
/**
* @satisfies {Record<ESBuildImportEnvKey, string>}
*/
const envRecord = {
AK_VERSION: AuthentikVersion,
AK_DOCS_URL: CurrentReleaseDocsURL.href,
AK_DOCS_RELEASE_NOTES_URL: ReleaseNotesURL.href,
AK_DOCS_PRE_RELEASE_URL: PreReleaseDocsURL.href,
AK_API_BASE_PATH: process.env.AK_API_BASE_PATH ?? "",
};
return {
...serializeEnvironmentVars(envRecord),
// We need to explicitly set this for NPM packages that use `process`
// to determine their environment.
"process.env.NODE_ENV": SerializedNodeEnvironment,
};
}