AddViteIntegration
NuGet: TechGems.ViteDotNet
Extension methods
Section titled “AddViteIntegration(IConfiguration)”
Program.cs
Section titled “AddViteIntegration(string)”
Program.cs
Section titled “AddViteIntegration(IEnumerable<string>)”
Program.cs
The
Section titled “The ViteDotNet configuration section”
Registers the Vite.NET integration on the dependency-injection container. Call it once in
Program.cs. Three overloads let you source the app directory name(s) from configuration or supply
them directly.
Namespace
Section titled “Namespace”using ViteDotNet;Overloads
Section titled “Overloads”AddViteIntegration(IConfiguration)
Section titled “AddViteIntegration(IConfiguration)”public static void AddViteIntegration( this IServiceCollection services, IConfiguration configuration)Reads the app directory name(s) from the ViteDotNet configuration section — either a single
string or an array of strings.
builder.Services.AddViteIntegration(builder.Configuration);| Parameter | Type | Description |
|---|---|---|
configuration | IConfiguration | The app configuration; the ViteDotNet section is read from it. |
AddViteIntegration(string)
Section titled “AddViteIntegration(string)”public static void AddViteIntegration( this IServiceCollection services, string appDirectory)Registers a single app directory directly, bypassing configuration.
builder.Services.AddViteIntegration("ReactApp");| Parameter | Type | Description |
|---|---|---|
appDirectory | string | The directory name of the integrated Vite app (e.g. "ReactApp"). |
AddViteIntegration(IEnumerable<string>)
Section titled “AddViteIntegration(IEnumerable<string>)”public static void AddViteIntegration( this IServiceCollection services, IEnumerable<string> appDirectories)Registers one or more app directories directly.
builder.Services.AddViteIntegration(new[] { "ReactApp", "SvelteApp" });| Parameter | Type | Description |
|---|---|---|
appDirectories | IEnumerable<string> | The directory names of the integrated Vite apps. |
The ViteDotNet configuration section
Section titled “The ViteDotNet configuration section”The IConfiguration overload reads this section, accepting either form:
{ "ViteDotNet": "ReactApp" }{ "ViteDotNet": [ "ReactApp", "SvelteApp" ] }If the section is missing or empty, no directories are registered and the tag helpers will throw when used. See Backend Configuration.
What it registers
Section titled “What it registers”The call wires up the services the tag helpers depend on (all singletons):
IViteConfigService— resolves which app directory a tag helper should use.IManifestExtractor— reads Vite’s productionmanifest.json.IDevManifestExtractor/IDevManifestCache— readmanifest.dev.json.IProdManifestExtractor/IProdManifestCache— readmanifest.prod.json.