From 192e3634b9dea3ba5e81eb4d87fe07d183d7967c Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Mon, 20 Apr 2026 14:08:40 -0700 Subject: [PATCH] Build fix --- Web/Resgrid.Web/Startup.cs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Web/Resgrid.Web/Startup.cs b/Web/Resgrid.Web/Startup.cs index a7cb5537..b74c4014 100644 --- a/Web/Resgrid.Web/Startup.cs +++ b/Web/Resgrid.Web/Startup.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Configuration; using System.Globalization; +using System.IO; using System.Net; using System.Net.Http; using System.Reflection; @@ -26,6 +27,7 @@ using Microsoft.Extensions.Caching.StackExchangeRedis; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; using Resgrid.Config; using Resgrid.Framework; @@ -375,10 +377,6 @@ public void ConfigureServices(IServiceCollection services) pipeline.AddCssBundle("/css/pub-bundle.css", "css/style.css", "css/animate.css", "lib/font-awesome/css/font-awesome.min.css"); - // Angular App code - pipeline.AddJavaScriptBundle("/js/ng/app.js", - "js/ng/vendor.js", "js/ng/runtime.js", "js/ng/polyfills.js", "js/ng/main.js"); - // Internal app style bundle pipeline.AddCssBundle("/css/int-bundle.css", "lib/font-awesome/css/font-awesome.min.css", "lib/metisMenu/dist/metisMenu.min.css", "lib/bootstrap-tour/build/css/bootstrap-tour.min.css", @@ -586,6 +584,26 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseCookiePolicy(cookiePolicyOptions); + // Serve the Vite ESM assets directly so legacy optimization doesn't rewrite module chunks. + app.UseWhen( + context => context.Request.Path.StartsWithSegments("/js/ng"), + clientApp => + { + clientApp.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, "js", "ng")), + RequestPath = "/js/ng", + OnPrepareResponse = context => + { + var cacheControl = context.Context.Request.Path.StartsWithSegments("/js/ng/chunks") + ? "public,max-age=31536000,immutable,no-transform" + : "no-cache,no-transform"; + + context.Context.Response.Headers["Cache-Control"] = cacheControl; + } + }); + }); + app.UseWebOptimizer(); app.UseStaticFiles(); app.UseRouting();