![]() |
VOOZH | about |
dotnet 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" />Directory.Packages.props
<PackageReference Include="SharpScss" />Project file
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.0Install as a Cake Addin
#tool nuget:?package=SharpScss&version=3.0.0Install as a Cake Tool
<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
libsass user custom importer callback in ScssOptions.TryImportnetstandard2.0 and net8.0+win-x86win-x64win-armwin-arm64linux-x64linux-armlinux-arm64linux-musl-x64linux-musl-armlinux-musl-arm64osx-x64osx-arm64For older .NET2.0, .NET3.5, .NET4.x+ and netstandard1.3, you need to download the 1.4.0 version.
SharpScss is available on 👁 NuGet
SharpScss API is simply composed of a main Scss class:
Scss.ConvertToCss: to convert a SCSS string to a CSSvar result = Scss.ConvertToCss("div {color: #FFF;}")
Console.WriteLine(result.Css);
Scss.ConvertFileToCss: to convert a SCSS file to a CSSvar 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;
}
});
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-arm64On .NET Core (net8.0), the runtime is selected based on the Runtime Identifier - RID of your project.
net8.0 with <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)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.
This software is released under the BSD-Clause 2 license.
Alexandre Mutel aka xoofx
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
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 |
Showing the top 7 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!
|
|
|
statiqdev/Statiq
Statiq is a flexible static site generator written in .NET.
|
|
|
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 10
|
|
|
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 | 137,100 | 11/2/2024 |
| 2.1.0 | 1,467 | 11/2/2024 |
| 2.0.0 | 893,336 | 6/28/2020 |
| 1.5.0 | 15,143 | 5/2/2020 |
| 1.4.0 | 679,081 | 6/25/2018 |
| 1.3.8 | 103,202 | 8/23/2017 |
| 1.3.7 | 4,580 | 5/14/2017 |
| 1.3.6 | 1,816 | 5/13/2017 |
| 1.3.5 | 1,812 | 5/13/2017 |
| 1.3.4 | 32,557 | 4/2/2017 |
| 1.3.3 | 1,821 | 4/2/2017 |
| 1.3.2 | 1,797 | 4/2/2017 |
| 1.3.1 | 1,829 | 4/2/2017 |
| 1.3.0 | 1,798 | 4/2/2017 |
| 1.2.0 | 5,107 | 6/27/2016 |
| 1.1.0 | 2,178 | 6/1/2016 |
| 1.0.1 | 2,743 | 4/5/2016 |
| 1.0.0 | 2,115 | 4/5/2016 |