PoeShared.Blazor.UnscopedCss 0.1.4
PoeShared.Blazor.UnscopedCss
Selective build-time post-processing for Blazor scoped CSS.
What it does
Blazor rewrites scoped component CSS into generated outputs and then bundles them into
{PackageId}.styles.css. This package adds build steps that can rewrite either the generated
component CSS or the final bundle outputs.
If a CSS file is marked with:
<None Update="EventViewer/AuraEventList.razor.css"
UnscopeCss="true" />
the package rewrites the matching generated CSS output and removes the Blazor scope attribute selectors.
This works for scoped source files like *.razor.css and generated bundle files like
{PackageId}.styles.css or {PackageId}.bundle.scp.css.
Consumer usage
- Add the package:
<PackageReference Include="PoeShared.Blazor.UnscopedCss" Version="1.0.2" PrivateAssets="all" />
- Opt in file-by-file:
<ItemGroup>
<None Update="EventViewer/AuraEventList.razor.css"
UnscopeCss="true" />
</ItemGroup>
Optional:
<None Update="EventViewer/AuraEventList.razor.css"
CssScope="ea-event-log"
UnscopeCss="true" />
Bundle-level usage:
<None Update="MyApp.styles.css"
CssScope="ea-event-log"
UnscopeCss="true" />
Notes
- The package rewrites generated
obj/.../scopedcss/.../*.rz.scp.cssfiles before bundling and can also rewrite bundled outputs like*.styles.cssafter bundling. - The unscoping pass is intentionally selective: only files marked with
UnscopeCssare touched. - The package is delivered through
buildTransitive, so adding the package reference is enough for consuming projects. - The task assembly is multi-targeted for both desktop MSBuild (
net472) anddotnet build(net8.0). - Logging is enabled by default and includes task duration in milliseconds.
PoeUnscopeAfterRewriteis still accepted as a compatibility alias, butUnscopeCssis the preferred metadata name.- If you toggle
UnscopeCsson an existing file, do a clean rebuild once so the generated scoped CSS is regenerated from source before the post-processing step runs again.
No packages depend on PoeShared.Blazor.UnscopedCss.
.NET Framework 4.7.2
- No dependencies.
.NET 8.0
- No dependencies.