Closed SteveSandersonMS closed 1 year ago
@SteveSandersonMS can you capture a binlog?
It's weird because we have tests for this in the SDK, so I would have expected those to break.
Yes, sending the binlog to you separately.
I checked with @javiercn and this isn't a bug. It's a configurable option. In the updated template, I've added the necessary flag to the csproj so that it works: https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/BlazorWeb-CSharp.Client.csproj.in#L8
Repro
dotnet new blazor --use-wasm
.Pages/Counter.razor.css
containingh1 { color: red; }
Expected: On the counter page, the title is red.
Actual: It's black
Alternatively, the same issue will probably occur if you use the Preview 7 project template and manually add an RCL, change the SDK to
BlazorWebAssembly
, and try to use one of its components with scoped CSS (but I didn't check that).Investigation
Looking at
MyBlazorApp.Styles.css
, I can see it does not have any line that does@import '_content/MyBlazorApp.Client/MyBlazorApp.Client.bundle.scp.css';
, so it's clearly not trying to load the scoped styles from the referenced project.This definitely seems specific to when the referenced project uses
Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"
. If I change that toSdk="Microsoft.NET.Sdk.Razor"
, then it does successfully reference and load the scoped CSS from it.Impact
This breaks scoped CSS in any component that is shared with WebAssembly (or completely breaks scoped CSS for WebAssembly-everywhere hosted projects).
cc @javiercn - any ideas?