Just to give an update on this.
For ASP.NET Core 2.1 or 2.0 with new template package
ASP.NET Core 2.1 (preview as the moment of writing) ships with updated angular templates which are available in 2.1 and resides in Microsoft.DotNet.Web.Spa.ProjectTemplates
package.
On ASP.NET Core 2.1 its installed with the .NET Core SDK. See docs.
Or it can be installed manually via
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0
or
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::*
to grab the latest version. The updated templates are based on Angular Cli and use the app.UseSpa(..:)
call whereas the old middleware used Webpack.
For ASP.NET Core 2.0
The old Angular SPA Template was based on JavaScriptServices which were shipped with ASP.NET Core up to version 2.0 or by running dotnet new -i "Microsoft.AspNetCore.SpaTemplates::*"
. See Available templates for dotnet new.
For ASP.NET Core 2.0 this is done by the WebpackDev middleware (see the app.UseWebpackDevMiddleware(...)
call in your Startup.cs.
if (env.IsDevelopment())
{
//app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true
});
}
else
{
app.UseExceptionHandler("/Home/Error");
}
it will use the webpack.config.js / webpack.config.vendor.js to build the files on startup or when it changes.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…