Bruce965.NodeDevServer
1.0.0
dotnet add package Bruce965.NodeDevServer --version 1.0.0
NuGet\Install-Package Bruce965.NodeDevServer -Version 1.0.0
<PackageReference Include="Bruce965.NodeDevServer" Version="1.0.0" />
paket add Bruce965.NodeDevServer --version 1.0.0
#r "nuget: Bruce965.NodeDevServer, 1.0.0"
// Install Bruce965.NodeDevServer as a Cake Addin
#addin nuget:?package=Bruce965.NodeDevServer&version=1.0.0
// Install Bruce965.NodeDevServer as a Cake Tool
#tool nuget:?package=Bruce965.NodeDevServer&version=1.0.0
Bruce965.NodeDevServer
Automatically start a Node development server alongside with an ASP.NET Core application.
Requirements
The .NET SDK must be installed.
Node.js also needs to be installed in order to start a Node development server.
Usage
If you don't have one already, create a new ASP.NET Core application.
dotnet new web --output MyAspNetCoreApp
Add the Bruce965.NodeDevServer NuGet package to your ASP.NET Core application.
dotnet add MyAspNetCoreApp package Bruce965.NodeDevServer
If you don't have one already, create a new Node.js application. You may use Vite or any other framework at your preference.
npm create -y vite -- my-frontend --template vanilla
Configure the Node development server in your Program.cs file.
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();
License
This project is licensed under the MIT license.
Some components may be available elsewhere under different license terms, please refer to the individual source files.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 86 | 5/4/2024 |