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 -->
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ Obj/
|
|||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
/wwwroot/dist/
|
||||
/ClientApp/dist/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
"apps": [
|
||||
{
|
||||
"root": "src",
|
||||
"outDir": "../wwwroot/dist",
|
||||
"assets": [
|
||||
"assets"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue