Skip to content

Commit 192e363

Browse files
committed
Build fix
1 parent 9623cd5 commit 192e363

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

Web/Resgrid.Web/Startup.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Configuration;
44
using System.Globalization;
5+
using System.IO;
56
using System.Net;
67
using System.Net.Http;
78
using System.Reflection;
@@ -26,6 +27,7 @@
2627
using Microsoft.Extensions.Caching.StackExchangeRedis;
2728
using Microsoft.Extensions.Configuration;
2829
using Microsoft.Extensions.DependencyInjection;
30+
using Microsoft.Extensions.FileProviders;
2931
using Microsoft.Extensions.Logging;
3032
using Resgrid.Config;
3133
using Resgrid.Framework;
@@ -375,10 +377,6 @@ public void ConfigureServices(IServiceCollection services)
375377
pipeline.AddCssBundle("/css/pub-bundle.css",
376378
"css/style.css", "css/animate.css", "lib/font-awesome/css/font-awesome.min.css");
377379

378-
// Angular App code
379-
pipeline.AddJavaScriptBundle("/js/ng/app.js",
380-
"js/ng/vendor.js", "js/ng/runtime.js", "js/ng/polyfills.js", "js/ng/main.js");
381-
382380
// Internal app style bundle
383381
pipeline.AddCssBundle("/css/int-bundle.css",
384382
"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
586584

587585
app.UseCookiePolicy(cookiePolicyOptions);
588586

587+
// Serve the Vite ESM assets directly so legacy optimization doesn't rewrite module chunks.
588+
app.UseWhen(
589+
context => context.Request.Path.StartsWithSegments("/js/ng"),
590+
clientApp =>
591+
{
592+
clientApp.UseStaticFiles(new StaticFileOptions
593+
{
594+
FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, "js", "ng")),
595+
RequestPath = "/js/ng",
596+
OnPrepareResponse = context =>
597+
{
598+
var cacheControl = context.Context.Request.Path.StartsWithSegments("/js/ng/chunks")
599+
? "public,max-age=31536000,immutable,no-transform"
600+
: "no-cache,no-transform";
601+
602+
context.Context.Response.Headers["Cache-Control"] = cacheControl;
603+
}
604+
});
605+
});
606+
589607
app.UseWebOptimizer();
590608
app.UseStaticFiles();
591609
app.UseRouting();

0 commit comments

Comments
 (0)