skip to Main Content

I found MS DOC about Css in razor. But it isn’t work with Scss file.

I resolve this problem by creating two files: css and scss. And use sass –watch. But I need write this every time, when creating new component.

2

Answers


  1. Unfortunately SASS is not supported for CSS Isolation feature of Blazor. At least, not at this moment.

    In our project, we use CSS Isolation for the CSS component isolation feature, but we use SASS files to manage our theme, for style we want accros the application.

    That being said, if you really need some SASS for an unique component, you totally can, by adding for example a wrapper with a specified id, and use this id in your scss file, with a dedicated name for it, for example MyComponent.scss.

    In addition, I’ve found this article, but I preferred to not use it because it is a bit heavy to setup, but up to you: https://joren-thijs.medium.com/how-to-add-scss-support-to-blazor-cd2a62995441

    Login or Signup to reply.
  2. You can use AspNetCore.SassCompiler which supports both normal and isolated scss. I believe it has a watch mode when using Blazor Server, WASM is not supported yet.

    It can also do minification with source mapping.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search