{"id":32485253,"url":"https://github.com/koenvzeijl/aspnetcore.sasscompiler","last_synced_at":"2025-10-27T04:20:05.505Z","repository":{"id":37669728,"uuid":"374768503","full_name":"koenvzeijl/AspNetCore.SassCompiler","owner":"koenvzeijl","description":"Sass Compiler Library for .NET Core 3.1/5.x/6.x/7.x without node, using dart-sass as a compiler","archived":false,"fork":false,"pushed_at":"2025-09-24T06:31:58.000Z","size":727590,"stargazers_count":238,"open_issues_count":9,"forks_count":29,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-10-20T18:44:49.297Z","etag":null,"topics":["asp-net-core","aspnetcore","blazor","csharp","dotnet","sass","scss"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/AspNetCore.SassCompiler/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koenvzeijl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-06-07T18:47:37.000Z","updated_at":"2025-09-24T06:24:20.000Z","dependencies_parsed_at":"2023-01-30T00:15:45.528Z","dependency_job_id":"1f765855-b849-41a5-8888-51cd4576e5af","html_url":"https://github.com/koenvzeijl/AspNetCore.SassCompiler","commit_stats":null,"previous_names":[],"tags_count":125,"template":false,"template_full_name":null,"purl":"pkg:github/koenvzeijl/AspNetCore.SassCompiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koenvzeijl%2FAspNetCore.SassCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koenvzeijl%2FAspNetCore.SassCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koenvzeijl%2FAspNetCore.SassCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koenvzeijl%2FAspNetCore.SassCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koenvzeijl","download_url":"https://codeload.github.com/koenvzeijl/AspNetCore.SassCompiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koenvzeijl%2FAspNetCore.SassCompiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281212437,"owners_count":26462316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","aspnetcore","blazor","csharp","dotnet","sass","scss"],"created_at":"2025-10-27T04:20:01.070Z","updated_at":"2025-10-27T04:20:05.490Z","avatar_url":"https://github.com/koenvzeijl.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AspNetCore.SassCompiler\n[![NuGet Version](https://img.shields.io/nuget/v/AspNetCore.SassCompiler.svg?style=flat)](https://www.nuget.org/packages/AspNetCore.SassCompiler/)\n\nSass Compiler Library for .NET 6 and above, without node.\n\n## Installation\nThe installation of this package is quite simple, you can install this package using NuGet with the following command:\n\n```shell\n# Package Manager\nPM\u003e Install-Package AspNetCore.SassCompiler\n\n# .NET CLI\ndotnet add package AspNetCore.SassCompiler\n```\n\n## Configuration\nAfter adding the package, the Sass styles from the Source (defaults to: Styles) will automatically be compiled into `.css` files in the TargetFolder (defaults to: wwwroot\\css) on build. \nYou can also adjust the default configuration in the appsettings.json or sasscompiler.json, do note that when using `appsettings.json` the configuration needs to be nested under a \"SassCompiler\" property, but when you're using `sasscompiler.json` the settings should _not_ be nested.\n\n### Available options\n\n| Name              | Default value                              | Description                                                                                                                                       |\n|-------------------|--------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| Source            | \"Styles\"                                   | The folder where all the .scss files reside, or an scss file                                                                                      |\n| Target            | \"wwwroot/css\"                              | When Source is a folder, the folder to output the generated .css files to\u003cbr/\u003eWhen Source is a file, the .css filepath where to save the css file |\n| Arguments         | \"--error-css\"                              | Arguments passed to the dart-sass executable. see [here](https://sass-lang.com/documentation/cli/dart-sass/) for available arguments.             |\n| GenerateScopedCss | true                                       | Enable/disable support for scoped scss                                                                                                            |\n| ScopedCssFolders  | [\"Views\", \"Pages\", \"Shared\", \"Components\"] | The folders in which .scss files are considered for scoped css                                                                                    |\n| IncludePaths      | []                                         | Add folders to search in when importing modules                                                                                                   |\n| Compilations      | []                                         | A list of source/target pairs that should be compiled. These will be added to the default Source and Target configured above.                     |\n| Configurations    | {}                                         | Add configuration to override specific options based on the build conifguration (e.g. Debug/Release)                                              |\n\n### Examples\n\n\u003cdetails open\u003e\n\u003csummary\u003eappsettings.json\u003c/summary\u003e\n\n```json\n{\n  \"SassCompiler\": {\n    \"Source\": \"Styles\",\n    \"Target\": \"wwwroot/css\",\n    \"Arguments\": \"--style=compressed\",\n    \"GenerateScopedCss\": true,\n    \"ScopedCssFolders\": [\"Views\", \"Pages\", \"Shared\", \"Components\"],\n    \"IncludePaths\": [],\n    \n    \"Compilations\": [\n      // Specify a specific file source/target in addition to the \"Styles\" -\u003e \"wwwroot/css\" Source/Target above\n      { \"Source\":  \"wwwroot/scss/site.scss\", \"Target\":  \"wwwroot/css/site.min.css\" },\n      // Or an extra directory to a different target directory\n      { \"Source\":  \"Lib/Styles\", \"Target\":  \"wwwroot/lib/css\" }\n    ],\n\n    // You can override specific options based on the build configuration\n    \"Configurations\": {\n      \"Debug\": { // These options apply only to Debug builds\n        \"Arguments\": \"--style=expanded\"\n      }\n    }\n  }\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003esasscompiler.json\u003c/summary\u003e\n\n```json\n{\n  \"Source\": \"Styles\",\n  \"Target\": \"wwwroot/css\",\n  \"Arguments\": \"--style=compressed\",\n  \"GenerateScopedCss\": true,\n  \"ScopedCssFolders\": [\"Views\", \"Pages\", \"Shared\", \"Components\"],\n  \"IncludePaths\": [],\n\n  \"Compilations\": [\n    // Specify a specific file source/target in addition to the \"Styles\" -\u003e \"wwwroot/css\" Source/Target above\n    { \"Source\":  \"wwwroot/scss/site.scss\", \"Target\":  \"wwwroot/css/site.min.css\" },\n    // Or an extra directory to a different target directory\n    { \"Source\":  \"Lib/Styles\", \"Target\":  \"wwwroot/lib/css\" }\n  ],\n  \n  // You can override specific options based on the build configuration\n  \"Configurations\": {\n    \"Debug\": { // These options apply only to Debug builds\n      \"Arguments\": \"--style=expanded\"\n    }\n  }\n}\n```\n\u003c/details\u003e\n\n\n## Sass watcher\nTo use the Sass watcher in your project, you must add the following code to your startup.cs:\n```csharp\npublic void ConfigureServices(IServiceCollection services) \n{\n  \n#if DEBUG\n  services.AddSassCompiler();\n#endif\n\n}\n```\n\nWe recommend adding the `#if DEBUG` statement to only use a watcher during debug mode.\n\n**Note:** The Sass watcher is currently not supported inside of a docker container. This should\nonly be an issue when you're developing inside of a docker container, running the published\napplication in docker is supported as the compiler is automatically run during the MSBuild publish\nstep. See [this](https://github.com/koenvzeijl/AspNetCore.SassCompiler/issues/44) issue for the progress.\n\n## Blazor WASM\nIf you use this with Blazor WebAssembly and want to customize the settings you need to use the sasscompiler.json, using appsettings.json is not supported.\n**The sass watcher is currently not supported for Blazor WebAssembly projects**, the MSBuild task is still available and will compile your scss during build and publish.\n\n## Compiling SCSS at runtime\nIt is also possible to compile SCSS files at runtime by using the `ISassCompiler` interface. By default however, the\nsass executables are not included in a Release build. To make be able to use the `ISassCompiler` interface in production\nyou need to add the following property to your csproj file: `\u003cSassCompilerIncludeRuntime\u003etrue\u003c/SassCompilerIncludeRuntime\u003e`.\n\nIf you don't want to use the hosted service to automatically compile your scss files during development, but do want to\nhave the `ISassCompiler` available, you can use the `AddSassCompilerCore()` method instead of the `AddSassCompiler()`\nmethod on the `IServiceCollection`. This will register what is required to use the `ISassCompiler` interface without\nregistering the hosted service.\n\n## Publish\n\nThis library also includes an MSBuild task that runs during the publish of your application. Because of this you don't need to include\nthe Sass Watcher in your release builds and you can safely add the generated .css files to the .gitignore file as they are regenerated during publish. \n\n### Alpine linux\nIf you're publishing your application inside an alpine linux container, you will need to install `gcompat` (using `apk add gcompat`) before running `dotnet build` or `dotnet publish`.\nThis is needed because the dart runtime which is what the `sass` compiler uses requires this package on alpine linux.\n\n## Examples\nTake a look at one of our examples on how it can be integrated in your project. We've created example projects for ASP.NET Core MVC, Blazor Server/Wasm and RazorClassLibrary projects.\n\n[MVC](https://github.com/koenvzeijl/AspNetCore.SassCompiler/tree/master/Samples/AspNetCore.SassCompiler.Sample)\n\n[Blazor Server](https://github.com/koenvzeijl/AspNetCore.SassCompiler/tree/master/Samples/AspNetCore.SassCompiler.BlazorSample)\n\n[Blazor WASM](https://github.com/koenvzeijl/AspNetCore.SassCompiler/tree/master/Samples/AspNetCore.SassCompiler.BlazorWasmSample)\n\n[Razor Class Library](https://github.com/koenvzeijl/AspNetCore.SassCompiler/tree/master/Samples/AspNetCore.SassCompiler.RazorClassLibrary)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoenvzeijl%2Faspnetcore.sasscompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoenvzeijl%2Faspnetcore.sasscompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoenvzeijl%2Faspnetcore.sasscompiler/lists"}