mohammad-hosein-shahpouri / AspNetCore.SpaServices.ViteDevelopmentServer

A library that allows you to use SPAs with Vite.js on ASP.NET Core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

A library that allows you to use SPAs with Vite.js on ASP.NET Core

License:MIT License


Languages

Language:C# 87.6%Language:CSS 6.0%Language:TypeScript 5.1%Language:HTML 1.2%