NodeDevServer
v1.0.0
Inicie automáticamente un servidor de desarrollo de nodo junto con una aplicación ASP.NET Core.
El SDK .NET debe estar instalado.
Node.js también debe instalarse para iniciar un servidor de desarrollo de nodos.
Si aún no tiene uno, cree una nueva aplicación ASP.NET Core.
dotnet new web --output MyAspNetCoreAppAgregue el paquete Bruce965.NodedevServer Nuget a su aplicación ASP.NET Core.
dotnet add MyAspNetCoreApp package Bruce965.NodeDevServerSi aún no tiene uno, cree una nueva aplicación Node.js. Puede usar Vite o cualquier otro marco a su preferencia.
npm create -y vite -- my-frontend --template vanillaConfigure el servidor de desarrollo de nodos en su archivo Program.CS .
WebApplicationBuilder builder = WebApplication . CreateBuilder ( args ) ;
// Configure the local Node development server.
builder . Services . AddNodeDevServer ( options =>
{
// You may need to tweak these options if you don't use Vite.
options . HostUri = "http://localhost:5173" ;
options . Path = "../my-frontend" ;
options . LaunchScript = "dev" ;
options . PackageManagers = [ "yarn" , "npm" ] ;
} ) ;
WebApplication app = builder . Build ( ) ;
// Some Node.js frameworks require this in order to support hot-reload.
app . UseWebSockets ( ) ;
app . UseRouting ( ) ;
app . UseEndpoints ( _ => { } ) ;
if ( app . Environment . IsDevelopment ( ) )
{
// In development, forward all requests to Node.js.
// The first request will automatically launch it.
app . UseNodeDevServer ( ) ;
}
else
{
// In production, use the pre-built files.
app . UseStaticFiles ( ) ;
}
app . Run ( ) ; Este proyecto tiene licencia bajo la licencia MIT.
Algunos componentes pueden estar disponibles en otro lugar en diferentes términos de licencia, consulte los archivos de origen individuales.