Skip to content
Quetzal Rivera edited this page Sep 16, 2023 · 3 revisions

Welcome to the Vite.AspNetCore wiki!

This library offers integration with ViteJS to be used in ASP.NET applications. If you want to use Vite to serve your scripts and styles while you are developing a MPA (Multi-Page Application) project, then this library is for you.

The main [README] (https://github.com/Eptagone/Vite.AspNetCore/blob/main/README.md) should contain enough information to configure Vite in most cases.

This wiki contains guides for some special settings.

How to configure a subfolder as output for my Vite assets?

By default, this package expects the Vite output (where your manifest file is located) to be your web root folder. If you want to use a subfolder like wwwroot/dist then you have to change the public base path. Specify it in your Vite configuration file (vite.config.ts) and also in the package configuration.

// vite.config.ts
const config: UserConfig = {
    // ...
    // @see https://vitejs.dev/config/shared-options.html#base
    base: '/dist/',
}
// program.cs
builder.Services.AddViteServices(new ViteOptions()
{
    Base = "/dist/",
});

Your paths should have the same prefix:

<link rel="stylesheet" vite-href="~/dist/main.css" />
<script type="module" vite-src="~/dist/main.ts"></script>
Clone this wiki locally