Table of Contents

Class NiteConfig

Namespace
Nite
Assembly
Nite.dll

The contents of nite.json. Both the middleware and the nite CLI read it, so dev and production builds agree on what gets compiled.

public sealed class NiteConfig
Inheritance
NiteConfig
Inherited Members

Fields

FileName

public const string FileName = "nite.json"

Field Value

string

Properties

AllDependencies

Everything to install: dependencies, dev dependencies and packages Nite needs itself.

[JsonIgnore]
public IReadOnlyDictionary<string, string> AllDependencies { get; }

Property Value

IReadOnlyDictionary<string, string>

ClientRoot

Folder (relative to the project) that holds client source. Default Client.

public string ClientRoot { get; init; }

Property Value

string

Css

Stylesheet options, named as in Vite's css config.

public NiteCssConfig Css { get; init; }

Property Value

NiteCssConfig

Dependencies

public Dictionary<string, string> Dependencies { get; init; }

Property Value

Dictionary<string, string>

DevDependencies

Installed for editor tooling (such as @types/react) but never bundled.

public Dictionary<string, string> DevDependencies { get; init; }

Property Value

Dictionary<string, string>

Entries

Extra entries relative to ClientRoot: modules that pages load with <nite-module>, or HTML pages served with MapNiteSpa. Islands and index.html (when it exists) are entries automatically.

public List<string> Entries { get; init; }

Property Value

List<string>

EnvPrefix

Environment variables with these prefixes (from .env files or the environment) are inlined into client code as import.meta.env.KEY and process.env.KEY. Others never reach the browser. Imported Vite projects use VITE_, Create React App ones REACT_APP_.

public List<string> EnvPrefix { get; init; }

Property Value

List<string>

FastRefresh

React Fast Refresh in development: component edits update in place and keep state. Needs react-refresh, which Nite installs as a dev dependency when React is a dependency.

public bool FastRefresh { get; init; }

Property Value

bool

Islands

Folder under ClientRoot whose modules can be used as islands.

public string Islands { get; init; }

Property Value

string

JsxImportSource

Package used for the automatic JSX runtime, such as react or preact.

public string JsxImportSource { get; init; }

Property Value

string

JsxInJs

Allow JSX in .js files, as Create React App does. Off by default, as in Vite.

public bool JsxInJs { get; init; }

Property Value

bool

Registry

Registry for this project's unscoped packages. Usually better set in .npmrc or the user config (see NiteSettings); this wins over both.

public string? Registry { get; init; }

Property Value

string

Renderer

The island renderer: react (default) or a module under ClientRoot that exports mount(element, component, props) and optionally returns an unmount function.

public string Renderer { get; init; }

Property Value

string

Target

esbuild target for production output. When it names only a JavaScript version, Nite adds the browsers Vite targets by default, so CSS gets lowered for them too.

public string Target { get; init; }

Property Value

string

Methods

Load(string)

public static NiteConfig Load(string projectDirectory)

Parameters

projectDirectory string

Returns

NiteConfig