Skip to content

mohammad-hosein-shahpouri/AspNetCore.SpaServices.ViteDevelopmentServer

Repository files navigation

AspNetCore.SpaServices.ViteDevelopmentServer

License: MIT Nuget

With this library you will be able to use Vite.js with your SPA in ASP.NET Core.

Vite.js is an opinionated build tool that enables lightning-fast development by relying on non-bundled JavaScript modules.

Install

$ dotnet add package AspNetCore.SpaServices.ViteDevelopmentServer

Usage

app.UseSpa(spa =>
{
    spa.Options.SourcePath = "ClientApp";

    if (app.Environment.IsDevelopment()) spa.UseViteDevelopmentServer(npmScript: "dev");
});

and if you want to use HMR WebSocket (Hot Reload) you should add

 server: {
  port: Number(process.env.PORT),
  hmr: {
      protocol: 'ws',
      host: 'localhost'
    }
}

to your vite.config.js or vite.config.ts file

License

Available under MIT License