Skip to content

CSS Isolation & RCL Support does not generate the correct CSS import for WASM Apps not hosted at root #41625

@philip-reed

Description

@philip-reed

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:

https://docs.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-6.0#razor-class-library-rcl-support

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

https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#static-assets-and-class-libraries-for-multiple-blazor-webassembly-apps

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.

image

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

image

Exceptions (if any)

NONE

.NET Version

6.0.201

Anything else?

Visual Studio 2022 - Running locally
ASPNETCORE_ENVIRONMENT=Development

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor Componentsfeature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssemblyfeature-css-isolationThis issue is related to CSS Isolation featurequestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions