excubo-ag / WebCompiler

Apache License 2.0
148 stars 29 forks source link

Enable Blazor CSS-Isolation #44

Closed seriouz closed 3 years ago

seriouz commented 3 years ago

Would it be possible to add an Analyzer that triggers the scss -> css transpilation when a blazor app gets builded? This way we could write scss files and benefit of the new Blazor CSS isolation which required css files.

stefanloerwald commented 3 years ago

Hi @seriouz,

this project is intended to be independent of UI frameworks. And while I personally also use Blazor, I don't see the need to do anything specific with this tool to integrate with Blazor.

It sounds to me that you want to just integrate the webcompiler command into your build. You can see how to do that in the Readme (https://github.com/excubo-ag/WebCompiler#msbuild). Then you simply write Component.razor.scss files, which will then get compiled as part of your project build. That should be enough to, as far as I can see (I am not using this myself, but I use the parts involved in different contexts).

Hope that helps, Stefan

seriouz commented 3 years ago

Ah okay, nice that it is already covered! I'll test it and give feedback if this is working. Probably a hint on the readme for Blazor CSS-Isolation is enough.

seriouz commented 3 years ago

I have another question: Can i run the command before the build <Target Name="CompileStaticAssets" AfterTargets="AfterBuild">....? The CSS isolation is part of the Blazor build and should run before it.

stefanloerwald commented 3 years ago

Yes. There's no restriction to when webcompiler can run, so you can integrate it anywhere in the build process. See https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets?view=vs-2019