If anyone bumps into this issue:
In .NET 9 there is now a built in feature for this:
What's new in ASP.NET Core 9.0 Static asset delivery optimization
See also: ASP.NET Core Blazor static files Static asset delivery in server-side Blazor apps
this also works for WASM.
Short version:
Adding Assets
<link rel="stylesheet" href="@Assets["bootstrap/bootstrap.min.css"]" />
<link rel="stylesheet" href="@Assets["app.css"]" />
<link rel="stylesheet" href="@Assets["BlazorSample.styles.css"]" />
Replacing middleware:
+app.MapStaticAssets();
-app.UseStaticFiles();