For Angular CLI 1.5.4 compatibility, build SPA to ClientApp/dist and serve its static files from there
This commit is contained in:
parent
c517ad3f65
commit
bf6942e616
|
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
<!-- Include the newly-built files in the publish output -->
|
<!-- Include the newly-built files in the publish output -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<DistFiles Include="wwwroot\dist\**; $(SpaRoot)dist-server\**" />
|
<DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
|
||||||
<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
|
<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
|
||||||
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
|
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
|
||||||
<RelativePath>%(DistFiles.Identity)</RelativePath>
|
<RelativePath>%(DistFiles.Identity)</RelativePath>
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ Obj/
|
||||||
|
|
||||||
# Visual Studio 2015 cache/options directory
|
# Visual Studio 2015 cache/options directory
|
||||||
.vs/
|
.vs/
|
||||||
/wwwroot/dist/
|
|
||||||
/ClientApp/dist/
|
|
||||||
|
|
||||||
# MSTest test Results
|
# MSTest test Results
|
||||||
[Tt]est[Rr]esult*/
|
[Tt]est[Rr]esult*/
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
"apps": [
|
"apps": [
|
||||||
{
|
{
|
||||||
"root": "src",
|
"root": "src",
|
||||||
"outDir": "../wwwroot/dist",
|
|
||||||
"assets": [
|
"assets": [
|
||||||
"assets"
|
"assets"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve --deploy-url=/dist/ --extract-css",
|
"start": "ng serve --extract-css",
|
||||||
"build": "ng build --deploy-url=/dist/ --extract-css",
|
"build": "ng build --extract-css",
|
||||||
"build:ssr": "npm run build -- --app=ssr",
|
"build:ssr": "npm run build -- --app=ssr",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@ namespace AngularSpa
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddMvc();
|
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.
|
// 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.UseStaticFiles();
|
||||||
|
app.UseSpaStaticFiles();
|
||||||
|
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +51,6 @@ namespace AngularSpa
|
||||||
|
|
||||||
app.UseSpa(spa =>
|
app.UseSpa(spa =>
|
||||||
{
|
{
|
||||||
spa.Options.DefaultPage = "/dist/index.html";
|
|
||||||
spa.Options.SourcePath = "ClientApp";
|
spa.Options.SourcePath = "ClientApp";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue