vite-envs
Version:
Env var in Vite at container startup
16 lines (13 loc) • 396 B
text/typescript
import { multiReplace } from "./tools/multiReplace";
export function substituteHtmPlaceholders(params: {
html: string;
env: Record<string, unknown>;
}): string {
const { html, env } = params;
return multiReplace({
"input": html,
"keyValues": Object.fromEntries(
Object.entries(env).map(([key, value]) => [`%${key}%`, `${value}`])
)
});
}