Advanced
Last updated
Last updated
This section exists to explain how to allow multiple Vite apps to run in the same ASP.NET Core application. This implies only changes to how the config is set up and requires no changes to how front ends are usually set up.
The only important distinction is that you will need more than one Vite app in your ASP.NET Core project to set this up. It should look like this:
For a setup like the previous one, your config will need to look like this:
You will also need two Razor pages and the way that the apps will be rendered will be a little different.
When using a named config, you will need to specify that you are doing so with the app-name
parameter.
The same is necessary with the Svelte.cshtml
page:
In Program.cs
, if you want to run both dev vite servers at once you will need to do tell the app like this:
There is another option for configuring declaratively without relying on config settings.
By using an integration config object, the tag helper will use that instead of anything that could be in appsettings.json
.
Just like for the backend, the front end plugin has a few customizable values that can be used in case you need to override defaults.
The overriding of these values is necessary every time you need to host more than one Vite application in your ASP.NET Core site. Always make sure that config values in both backend and front end match, as it is necessary for the integration to work correctly.