aspnetcore: CSS Isolation & RCL Support does not generate the correct CSS import for WASM Apps not hosted at root
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The documentation here states that CSS from the RCL’s stylesheet is imported at the top of the app’s stylesheet:
However, if the Blazor app is not hosted from root (for example where multiple WASM apps are being hosted from a single server at different urls), the URL created in the import statement ignores the StaticWebAssetBasePath
.
However the documentation for hosting multiple WASM applications states that RCL CSS should be added manually to index.html
Adding the RCL CSS this way solves the problem, but the RCL is still also imported into the parent app CSS, and results in a 404. However adding the base path to the imported css file path results in a 200.
Expected Behavior
Either the CSS Import should use the correct url, or there should be a way to disable the import statement and link the css manually in Index.html
Steps To Reproduce
Example App here: https://github.com/philip-reed/HostedBlazorWithBaseHrefCss
The BlazorApp1.Client has a reference to RasorClassLibrary1 which has a SharedCounter component with custom CSS. BlazorApp1.Client is served from /demo
Exceptions (if any)
NONE
.NET Version
6.0.201
Anything else?
Visual Studio 2022 - Running locally ASPNETCORE_ENVIRONMENT=Development
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (9 by maintainers)
@philip-reed … When you reach a final working approach based on @javiercn’s remarks, please comment on the docs issue that I opened at …
https://github.com/dotnet/AspNetCore.Docs/issues/25836
… with the changes you made to your repro project at …
https://github.com/philip-reed/HostedBlazorWithBaseHrefCss
… to get it working. That will aid in updating docs for this scenario.
@guardrex can we get the docs updated for this topic?