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" />
paket add SharpScss --version 3.0.0
#r "nuget: SharpScss, 3.0.0"
// Install SharpScss as a Cake Addin #addin nuget:?package=SharpScss&version=3.0.0 // Install SharpScss as a Cake Tool #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
libsass
user custom importer callback inScssOptions.TryImport
- Supports for
netstandard2.0
andnet8.0
+ - Supports the following platforms:
win-x86
win-x64
win-arm
win-arm64
linux-x64
linux-arm
linux-arm64
linux-musl-x64
linux-musl-arm
linux-musl-arm64
osx-x64
osx-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 aSCSS
string to aCSS
var result = Scss.ConvertToCss("div {color: #FFF;}")
Console.WriteLine(result.Css);
Scss.ConvertFileToCss
: to convert aSCSS
file 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-x86
win-x64
win-arm
win-arm64
linux-x64
linux-arm
linux-arm64
linux-musl-x64
linux-musl-arm
linux-musl-arm64
osx-x64
osx-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.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)
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. |
.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. |
|
Sakura.AspNetCore.Tools.WebCompiler
This tools is used to compile client web files in your .NET Core application. |
GitHub repositories (6)
Showing the top 5 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
.NET Workflow Engine and Automation Platform
|
|
statiqdev/Statiq.Framework
A flexible and extensible static content generation framework for .NET.
|
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 789 | 11/2/2024 |
2.1.0 | 108 | 11/2/2024 |
2.0.0 | 540,100 | 6/28/2020 |
1.5.0 | 14,457 | 5/2/2020 |
1.4.0 | 512,646 | 6/25/2018 |
1.3.8 | 98,567 | 8/23/2017 |
1.3.7 | 3,328 | 5/14/2017 |
1.3.6 | 1,034 | 5/13/2017 |
1.3.5 | 1,037 | 5/13/2017 |
1.3.4 | 30,402 | 4/2/2017 |
1.3.3 | 1,018 | 4/2/2017 |
1.3.2 | 1,034 | 4/2/2017 |
1.3.1 | 1,049 | 4/2/2017 |
1.3.0 | 1,048 | 4/2/2017 |
1.2.0 | 4,243 | 6/27/2016 |
1.1.0 | 1,401 | 6/1/2016 |
1.0.1 | 1,937 | 4/5/2016 |
1.0.0 | 1,320 | 4/5/2016 |