From f5276e5a14be4d74ebcdfb62640f3b98b8d6ec3e Mon Sep 17 00:00:00 2001 From: UseMuse Date: Wed, 16 Oct 2019 15:47:39 +0300 Subject: [PATCH] Migration from ASP.NET Core 2.2 to 3.0, adaptation of the project for asp core 3.0 with hot reload by Westwind.AspnetCore.LiveReload --- content/Startup.cs | 18 +++++++++++++----- content/Vue2Spa.csproj | 21 +++++++++++++++++---- content/appsettings.Development.json | 8 ++++++++ content/appsettings.json | 3 +++ content/package.json | 8 ++++---- content/web.config | 15 +++++++++------ 6 files changed, 54 insertions(+), 19 deletions(-) diff --git a/content/Startup.cs b/content/Startup.cs index bfa43ce..8604cf8 100644 --- a/content/Startup.cs +++ b/content/Startup.cs @@ -4,7 +4,9 @@ using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Vue2Spa.Providers; +using Westwind.AspNetCore.LiveReload; namespace Vue2Spa { @@ -20,25 +22,31 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddLiveReload(config => + { + + }); // Add framework services. - services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(opt => opt.EnableEndpointRouting = false) + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); // Simple example with dependency injection for a data provider. services.AddSingleton(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + [System.Obsolete] + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { + app.UseLiveReload(); app.UseDeveloperExceptionPage(); - // Webpack initialization with hot-reload. + // Webpack initialization without hot-reload. app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { - HotModuleReplacement = true, + HotModuleReplacement = false, }); } else diff --git a/content/Vue2Spa.csproj b/content/Vue2Spa.csproj index 279cf9e..16b4b01 100644 --- a/content/Vue2Spa.csproj +++ b/content/Vue2Spa.csproj @@ -1,10 +1,7 @@ - netcoreapp2.2 + netcoreapp3.0 - - - @@ -12,7 +9,23 @@ + + + + + + + + + + + + + + + + diff --git a/content/appsettings.Development.json b/content/appsettings.Development.json index e203e94..8372a92 100644 --- a/content/appsettings.Development.json +++ b/content/appsettings.Development.json @@ -5,5 +5,13 @@ "System": "Information", "Microsoft": "Information" } + }, + "WebRoot": "null", + "Port": 5000, + "LiveReload": { + "LiveReloadEnabled": true, + "ClientFileExtensions": ".cshtml,.css,.js,.htm,.html,.ts,.wc", + "ServerRefreshTimeout": 3000, + "WebSocketUrl": "/__livereload" } } diff --git a/content/appsettings.json b/content/appsettings.json index 6cf0b42..d31b975 100644 --- a/content/appsettings.json +++ b/content/appsettings.json @@ -3,5 +3,8 @@ "LogLevel": { "Default": "Warning" } + }, + "LiveReload": { + "LiveReloadEnabled": false } } diff --git a/content/package.json b/content/package.json index e509d92..75545a0 100644 --- a/content/package.json +++ b/content/package.json @@ -75,9 +75,9 @@ "style-loader": "^0.23.1", "url-loader": "^1.1.2", "vue-loader": "^15.6.2", - "webpack": "^4.29.0", - "webpack-cli": "^3.2.1", - "webpack-dev-server": "^3.1.14", - "webpack-hot-middleware": "^2.21.2" + "webpack": "^4.29.6", + "webpack-cli": "^3.2.3", + "webpack-dev-middleware": "^3.6.0", + "webpack-hot-middleware": "^2.24.3" } } diff --git a/content/web.config b/content/web.config index a8d6672..a7fb2f9 100644 --- a/content/web.config +++ b/content/web.config @@ -1,14 +1,17 @@ - + - - - + - + + + + + + - + \ No newline at end of file