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
Production
public const string Production = "production"
Field Value
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
projectNiteProjectmodestringenvironmentFunc<string, string>
Returns
FileNames(string)
public static IEnumerable<string> FileNames(string mode)
Parameters
modestring
Returns
IsEnvFile(string)
public static bool IsEnvFile(string fileName)
Parameters
fileNamestring
Returns
Load(NiteProject, string, Func<string, string?>?)
public static IReadOnlyDictionary<string, string> Load(NiteProject project, string mode, Func<string, string?>? environment = null)
Parameters
projectNiteProjectmodestringenvironmentFunc<string, string>