Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mohammad-hosein-shahpouri/AspNetCore.SpaServices.ViteDevelopmentServer

A library that allows you to use SPAs with Vite.js on ASP.NET Core
https://github.com/mohammad-hosein-shahpouri/AspNetCore.SpaServices.ViteDevelopmentServer

asp-net-core c-charp javascript typescript vite vitejs

Last synced: 7 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# AspNetCore.SpaServices.ViteDevelopmentServer
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Nuget](https://img.shields.io/nuget/v/AspNetCore.SpaServices.ViteDevelopmentServer)](https://www.nuget.org/packages/AspNetCore.SpaServices.ViteDevelopmentServer/)

With this library you will be able to use [Vite.js](https://vitejs.dev) 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
```c#
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";

if (app.Environment.IsDevelopment()) spa.UseViteDevelopmentServer(npmScript: "dev", useHttps: true);
});
```
and if you want to use HMR WebSocket (Hot Reload) you should add
```typescript
server: {
port: Number(process.env.PORT),
hmr: {
protocol: 'wss',
host: 'localhost',
port: Number(process.env.HMR_PORT)
}
}
```
to your vite.config.js or vite.config.ts file

## License

Available under MIT License