[]previous and next page

applyServerEnv

Puts variables from the env files into process.env, for server code that reads process.env.NAME (the same way production does, where the platform sets them).

Puts variables from the env files into process.env, for server code that reads process.env.NAME (the same way production does, where the platform sets them). A variable that is already set is left alone, so a value given on the command line or by the platform wins over a file; NODE_ENV is never taken from a file.

Import#

ts
import { applyServerEnv } from "@shadow-js/dusk/vite";

Signature#

ts
function applyServerEnv(
  values: Readonly<Record<string, string>>,
  target: Record<string, string | undefined> = process.env,
): string[]

Parameters#

Name Description
values The variables, from loadServerEnv.
target The environment to fill. Default process.env.

Returns#

The names that were set, sorted.

Examples#

ts
applyServerEnv(loadServerEnv("development", root)); // ["DATABASE_URL"]