For Angular CLI 1.5.4 compatibility, build SPA to ClientApp/dist and serve its static files from there

This commit is contained in:
Steve Sanderson 2017-11-23 11:28:40 +00:00
parent c517ad3f65
commit bf6942e616
5 changed files with 10 additions and 7 deletions

View File

@ -55,7 +55,7 @@
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\dist\**; $(SpaRoot)dist-server\**" />
<DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>

View File

@ -28,8 +28,6 @@ Obj/
# Visual Studio 2015 cache/options directory
.vs/
/wwwroot/dist/
/ClientApp/dist/
# MSTest test Results
[Tt]est[Rr]esult*/

View File

@ -6,7 +6,6 @@
"apps": [
{
"root": "src",
"outDir": "../wwwroot/dist",
"assets": [
"assets"
],

View File

@ -4,8 +4,8 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --deploy-url=/dist/ --extract-css",
"build": "ng build --deploy-url=/dist/ --extract-css",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
"build:ssr": "npm run build -- --app=ssr",
"test": "ng test",
"lint": "ng lint",

View File

@ -19,6 +19,12 @@ namespace AngularSpa
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -34,6 +40,7 @@ namespace AngularSpa
}
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseMvc(routes =>
{
@ -44,7 +51,6 @@ namespace AngularSpa
app.UseSpa(spa =>
{
spa.Options.DefaultPage = "/dist/index.html";
spa.Options.SourcePath = "ClientApp";
/*