|
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Configuration; |
4 | 4 | using System.Globalization; |
| 5 | +using System.IO; |
5 | 6 | using System.Net; |
6 | 7 | using System.Net.Http; |
7 | 8 | using System.Reflection; |
|
26 | 27 | using Microsoft.Extensions.Caching.StackExchangeRedis; |
27 | 28 | using Microsoft.Extensions.Configuration; |
28 | 29 | using Microsoft.Extensions.DependencyInjection; |
| 30 | +using Microsoft.Extensions.FileProviders; |
29 | 31 | using Microsoft.Extensions.Logging; |
30 | 32 | using Resgrid.Config; |
31 | 33 | using Resgrid.Framework; |
@@ -375,10 +377,6 @@ public void ConfigureServices(IServiceCollection services) |
375 | 377 | pipeline.AddCssBundle("/css/pub-bundle.css", |
376 | 378 | "css/style.css", "css/animate.css", "lib/font-awesome/css/font-awesome.min.css"); |
377 | 379 |
|
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 | | - |
382 | 380 | // Internal app style bundle |
383 | 381 | pipeline.AddCssBundle("/css/int-bundle.css", |
384 | 382 | "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 |
586 | 584 |
|
587 | 585 | app.UseCookiePolicy(cookiePolicyOptions); |
588 | 586 |
|
| 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 | + |
589 | 607 | app.UseWebOptimizer(); |
590 | 608 | app.UseStaticFiles(); |
591 | 609 | app.UseRouting(); |
|
0 commit comments