SharpScss 3.0.0
Prefix Reserveddotnet add package SharpScss --version 3.0.0
NuGet\Install-Package SharpScss -Version 3.0.0
<PackageReference Include="SharpScss" Version="3.0.0" />
<PackageVersion Include="SharpScss" Version="3.0.0" />
<PackageReference Include="SharpScss" />
paket add SharpScss --version 3.0.0
#r "nuget: SharpScss, 3.0.0"
#:package SharpScss@3.0.0
#addin nuget:?package=SharpScss&version=3.0.0
#tool nuget:?package=SharpScss&version=3.0.0
SharpScss

<img align="right" width="160px" height="160px" src="https://raw.githubusercontent.com/xoofx/SharpScss/master/img/SharpScss.png">
SharpScss is a P/Invoke .NET wrapper around libsass to convert SCSS to CSS.
Based on the version of
libsass 3.6.6
Features
- Pure P/Invoke .NET wrapper, no C++/CLI involved
- Supports converting from a string or from a file
- Supports include paths
- Supports for source maps
- Supports for
libsassuser custom importer callback inScssOptions.TryImport - Supports for
netstandard2.0andnet8.0+ - Supports the following platforms:
win-x86win-x64win-armwin-arm64linux-x64linux-armlinux-arm64linux-musl-x64linux-musl-armlinux-musl-arm64osx-x64osx-arm64
For older .NET2.0, .NET3.5, .NET4.x+ and netstandard1.3, you need to download the 1.4.0 version.
Download
Usage
SharpScss API is simply composed of a main Scss class:
Scss.ConvertToCss: to convert aSCSSstring to aCSS
var result = Scss.ConvertToCss("div {color: #FFF;}")
Console.WriteLine(result.Css);
Scss.ConvertFileToCss: to convert aSCSSfile to aCSS
var result = Scss.ConvertFileToCss("test.scss")
Console.WriteLine(result.Css);
Using the ScssOptions you can specify additional parameters:
var result = Scss.ConvertToCss(@"div {color: #FFF;}", new ScssOptions()
{
InputFile = "Test.scss",
OutputFile = "Test.css", // Note: It will not generate the file,
// only used for exception reporting
// includes and source maps
GenerateSourceMap = true
});
Console.WriteLine(result.Css);
Console.WriteLine(result.SourceMap);
You can use also custom dynamic import through the delegate ScssOptions.TryImport. Note that in that cases ScssOptions.IncludePaths is not used
and it is the responsability of the TryImport to perform the resolution (e.g on a virtual file system):
var result = Scss.ConvertToCss(@"@import ""foo"";", new ScssOptions()
{
InputFile = "test.scss",
TryImport = (ref string file, string path, out string scss, out string map) =>
{
// Add resolve the file
// file = resolvedFilePath; // Can change the file resolved
scss = ...; // TODO: handle the loading of scss for the specified file
map = null;
return true;
}
});
Runtime
SharpScss depends on the native runtime libsass. This runtime is compiled for the following platform/runtime:
win-x86win-x64win-armwin-arm64linux-x64linux-armlinux-arm64linux-musl-x64linux-musl-armlinux-musl-arm64osx-x64osx-arm64
On .NET Core (net8.0), the runtime is selected based on the Runtime Identifier - RID of your project.
- You can add to your csproj the specific targeting runtimes your
net8.0with<RuntimeIdentifiers>win-x86;linux-x64</RuntimeIdentifiers>or<RuntimeIdentifier>if you have only one runtime to target (See Additions to the csproj format for .NET Core)
Build
Currently, the compiled version of libsass shipped with SharpScss is a custom build from the fork xoofx/libsass
This fork is mainly allowing to compile libsass without the MSVC C/C++ Runtime on Windows and provide a GitHub CI action to compile all different platforms.
License
This software is released under the BSD-Clause 2 license.
Author
Alexandre Mutel aka xoofx
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (9)
Showing the top 5 NuGet packages that depend on SharpScss:
| Package | Downloads |
|---|---|
|
Statiq.Sass
Statiq is a configurable static content generation framework. This library provides support for parsing Sass CSS content. |
|
|
Wyam.Sass
Wyam is a simple to use, highly modular, and extremely configurable static content generator. This library provides support for parsing Sass CSS content. |
|
|
Stasistium.Sass
Package Description |
|
|
Fynydd.Halide
A treasure trove of useful extension methods, helpers, and tools for ASP.NET and MVC. Halide includes extension methods for manipulating base types (like strings, byte arrays, numerics), and static helper classes for HTTP and REST helpers, SQL data readers, security and encryption, file compression, SCSS compilation, CSS and JavaScript minification, and more. Halide requires no commercial third party components. You have all the source code, an MIT license, sunshine, and puppies. |
|
|
NodeAssets.Compilers.Sass
.NET based minification compilers for scss based on the NSass/libsass projects |
GitHub repositories (6)
Showing the top 6 popular GitHub repositories that depend on SharpScss:
| Repository | Stars |
|---|---|
|
TCNOco/TcNo-Acc-Switcher
A Super-fast account switcher for Steam, Battle.net, Epic Games, Origin, Riot, Ubisoft and many others!
|
|
|
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 7
|
|
|
ligershark/WebOptimizer
A bundler and minifier for ASP.NET Core
|
|
|
aelassas/wexflow
Workflow Automation Engine
|
|
|
statiqdev/Statiq.Framework
A flexible and extensible static content generation framework for .NET.
|
|
|
Wyamio/Wyam
A modular static content and static site generator.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 52,301 | 11/2/2024 |
| 2.1.0 | 746 | 11/2/2024 |
| 2.0.0 | 758,207 | 6/28/2020 |
| 1.5.0 | 14,719 | 5/2/2020 |
| 1.4.0 | 604,919 | 6/25/2018 |
| 1.3.8 | 102,042 | 8/23/2017 |
| 1.3.7 | 4,093 | 5/14/2017 |
| 1.3.6 | 1,374 | 5/13/2017 |
| 1.3.5 | 1,379 | 5/13/2017 |
| 1.3.4 | 32,041 | 4/2/2017 |
| 1.3.3 | 1,380 | 4/2/2017 |
| 1.3.2 | 1,358 | 4/2/2017 |
| 1.3.1 | 1,393 | 4/2/2017 |
| 1.3.0 | 1,359 | 4/2/2017 |
| 1.2.0 | 4,668 | 6/27/2016 |
| 1.1.0 | 1,750 | 6/1/2016 |
| 1.0.1 | 2,308 | 4/5/2016 |
| 1.0.0 | 1,665 | 4/5/2016 |