NodeDevServer
v1.0.0
ASP.NET Core 응용 프로그램과 함께 노드 개발 서버를 자동으로 시작하십시오.
.NET SDK를 설치해야합니다.
노드 개발 서버를 시작하려면 Node.js도 설치해야합니다.
이미 없으면 새 ASP.NET Core 응용 프로그램을 작성하십시오.
dotnet new web --output MyAspNetCoreAppBruce965.NodedEvserver Nuget 패키지를 ASP.NET Core 응용 프로그램에 추가하십시오.
dotnet add MyAspNetCoreApp package Bruce965.NodeDevServer이미없는 경우 새 node.js 응용 프로그램을 작성하십시오. 선호도에 Vite 또는 기타 프레임 워크를 사용할 수 있습니다.
npm create -y vite -- my-frontend --template vanillaProgram.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 ( ) ; 이 프로젝트는 MIT 라이센스에 따라 라이센스가 부여됩니다.
일부 구성 요소는 다른 라이센스 용어로 다른 곳에서 사용할 수 있습니다. 개별 소스 파일을 참조하십시오.