Table of Contents

Class NiteEnvironment

Namespace
Nite
Assembly
Nite.dll

Public environment variables for client code, the way Vite does it: values come from .env, .env.local, .env.[mode] and .env.[mode].local in the project folder (later files win) and from the process environment (which wins over files), but only keys with one of the configured prefixes reach the browser. Everything else stays on the server.

public static class NiteEnvironment
Inheritance
NiteEnvironment
Inherited Members

Remarks

Code sees them as import.meta.env.KEY (with MODE, DEV, PROD, BASE_URL and SSR alongside, as in Vite) and as process.env.KEY (as in Create React App). Values are inlined at compile time.

Fields

Development

public const string Development = "development"

Field Value

string

Production

public const string Production = "production"

Field Value

string

Methods

DefineFlags(NiteProject, string, Func<string, string?>?)

esbuild --define flags that inline the public variables.

public static List<string> DefineFlags(NiteProject project, string mode, Func<string, string?>? environment = null)

Parameters

project NiteProject
mode string
environment Func<string, string>

Returns

List<string>

FileNames(string)

public static IEnumerable<string> FileNames(string mode)

Parameters

mode string

Returns

IEnumerable<string>

IsEnvFile(string)

public static bool IsEnvFile(string fileName)

Parameters

fileName string

Returns

bool

Load(NiteProject, string, Func<string, string?>?)

public static IReadOnlyDictionary<string, string> Load(NiteProject project, string mode, Func<string, string?>? environment = null)

Parameters

project NiteProject
mode string
environment Func<string, string>

Returns

IReadOnlyDictionary<string, string>