Skip to content

Migrating from v0 packages

The previous versions of the packages (v0) utilized more configuration and required the developer to keep said configuration synchronized.

The v0 versions of the packages rework how the front end and back end share configuration. The Vite plugin now emits manifest files that describe each app. With this, the backend only needs to know where the application is.

AreaBefore (v0)Now
Backend configFull per-app settings (entrypoint, container id, port, framework) in appsettings.jsonJust the app directory name(s) under ViteDotNet
App identityConfigured explicitlyDerived from SPA configuration automatically
Dev/prod metadataBackend configmanifest.dev.json / manifest.prod.json in wwwroot

Update the NuGet package and the Vite plugin to their latest versions:

Terminal window
dotnet add package TechGems.ViteDotNet
Terminal window
cd ReactApp && npm install vite-dotnet@latest

Pass your entrypoint and container element id to the plugin, and make sure it’s registered after your framework plugin:

vite.config.ts
export default defineConfig({
plugins: [
react(),
ViteDotNetPlugin('src/main.tsx', 'root'),
],
})

Replace the previous per-app configuration object with just the directory name(s):

appsettings.Development.json
{
"ViteDotNet": "ReactApp"
}

or, for several apps:

{
"ViteDotNet": [ "ReactApp", "SvelteApp" ]
}

The tag helpers are <dev-vite-scripts> and <prod-vite-scripts>, selected by the app directory name via app-name (optional when only one app is configured):

<dev-vite-scripts app-name="ReactApp" />

Run the dev server (npm run dev) or a production build (npm run build) so the plugin writes the new manifests into wwwroot. The back end reads them from there.