Giter Site home page Giter Site logo

libsass-net's Introduction

libsass-net

Join the chat at https://gitter.im/darrenkopp/libsass-net

AppVeyor CI Status

A lightweight wrapper around libsass

Requires Visual C++ 2015 Redistributable or Choco

Usage

Please read this guide

Please use the Alpha versions for the time being. the "Stable" versions are unstable and slow. https://www.nuget.org/packages/libsassnet.Web/2.3.0-alpha-1
https://www.nuget.org/packages/libsassnet/3.3.7-alpha-2

Versioning

From now on, we will try to maintain the following versioning schema:

LibSassNet's version will be the same as http://github.com/sass/LibSass

LibSass.Web's version is independant of LibSass and will be following SemVer

Current version LibSassNet : 3.3.6

Currently implemented version of LibSass = 3.3.6

Current version of LibSassNet.Web 2.2

libsass-net's People

Contributors

aloneartist avatar am11 avatar bobbynewmark avatar darrenkopp avatar gerseras avatar gitter-badger avatar nikolasivkov avatar nschonni avatar vadimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libsass-net's Issues

Caching

Just wondering if you have any plans on adding caching support to the handler?

@import throws SassCompileException with message "Unknown error occurred"

If there is a @import in the input file I get a SassCompileException with the message "Unknown error occurred". The file _reset.scss exists and is in the same folder. Compiling SASS without @import works.

/* base.scss */

@import 'reset';
//@import '_reset.scss'; doesn't work either
SassCompiler sc = new SassCompiler();
string inputPath = "C:\\Users\\unknown\\Desktop\\tmp\\base.scss";

try
{
    CompileFileResult result = sc.CompileFile(inputPath);
    Console.WriteLine(result.CSS);
}
catch (SassCompileException sce)
{
    Console.WriteLine(sce.Message);     
}

Console.ReadKey();

SourceCommentsMode should be bool

In libsass version 3 source_comments property got changed from struct to simple bool (see sass_interface.h), so there is no need in SourceCommentsMode enum in libsass-net as well.

By the way, thanks for such quick migration to newest libsass ๐Ÿ‘

Wrong encoding?

Hi,

When I have a "content: '\e003';" in scss the file gets converted to "content: "รฎโ‚ฌฦ’";" instead of keeping the "\e003" ascii value.
This is using the CompileFile function.
KR

MK

@import statements not processed

Hi!
I'm trying to implement this in order to compile my Sass in a bundle for my MVC project.

In my BundleConfig.cs file, I have the following:
bundles.Add(new StyleBundle("~/bundles/styles").Include("~/Content/2016-Q1/styles/_CCC/sass/styles.scss"));

styles.scss is my main SASS file, with a bunch of @import statements.

When I build the project and load a View, the CSS file simply the @import statements minimized:
@import"_vars.scss";@import"includes/reset.scss";@import"includes/box-sizing.scss";@import"includes/csswizardry-grids.scss";@import"includes/typecsset.scss";@import"includes/flexbox.scss";@import"_mixins.scss";@import"_namespaces.scss";@import"_hacks.scss";

Am I missing something? The bundle is loading. The issue is that the SASS isn't compiling.

Any help would be appreciated.

Thanks!

-Eric

Valid SASS fails to compile

Hey Darren,

I've tried compiling the following SASS which fails on LibSassNet for some reason which I can sucessfully compile by using Grunt-sass instead:

C:/Dev/Projects/M/src/M.Web/content/lib/materialize/sass/components/color:366: expected 'in' keyword in @each directive

   at LibSassNet.SassCompiler.CompileFile(String inputPath, OutputStyle outputStyle, String sourceMapPath, SourceCommentsMode sourceComments, Int32 precision, IEnumerable`1 additionalIncludePaths)
   at SassyStudio.Integration.LibSass.LibSassNetDocumentCompiler.Compile(FileInfo source, FileInfo output)
   at SassyStudio.Integration.LibSass.LibSassNetDocumentCompiler.<>c__DisplayClass3.<CompileAsync>b__2()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SassyStudio.Editor.GenerateCssOnSave.<GenerateCss>d__14.MoveNext()

Here's the validated SCSS

// Utility Color Classes

//.success {
//
//}

// Google Color Palette defined: http://www.google.com/design/spec/style/color.html


$materialize-red: (
  "lighten-5":  #fdeaeb,
  "lighten-4":  #f8c1c3,
  "lighten-3":  #f3989b,
  "lighten-2":  #ee6e73,
  "lighten-1":  #ea454b,
  "base":       #e51c23,
  "darken-1":   #d0181e,
  "darken-2":   #b9151b,
  "darken-3":   #a21318,
  "darken-4":   #8b1014,
);

$red: (
  "lighten-5":  #FFEBEE,
  "lighten-4":  #FFCDD2,
  "lighten-3":  #EF9A9A,
  "lighten-2":  #E57373,
  "lighten-1":  #EF5350,
  "base":       #F44336,
  "darken-1":   #E53935,
  "darken-2":   #D32F2F,
  "darken-3":   #C62828,
  "darken-4":   #B71C1C,
  "accent-1":    #FF8A80,
  "accent-2":    #FF5252,
  "accent-3":    #FF1744,
  "accent-4":    #D50000
);

$pink: (
  "lighten-5":  #fce4ec,
  "lighten-4":  #f8bbd0,
  "lighten-3":  #f48fb1,
  "lighten-2":  #f06292,
  "lighten-1":  #ec407a,
  "base":       #e91e63,
  "darken-1":   #d81b60,
  "darken-2":   #c2185b,
  "darken-3":   #ad1457,
  "darken-4":   #880e4f,
  "accent-1":    #ff80ab,
  "accent-2":    #ff4081,
  "accent-3":    #f50057,
  "accent-4":    #c51162
);

$purple: (
  "lighten-5":  #f3e5f5,
  "lighten-4":  #e1bee7,
  "lighten-3":  #ce93d8,
  "lighten-2":  #ba68c8,
  "lighten-1":  #ab47bc,
  "base":       #9c27b0,
  "darken-1":   #8e24aa,
  "darken-2":   #7b1fa2,
  "darken-3":   #6a1b9a,
  "darken-4":   #4a148c,
  "accent-1":    #ea80fc,
  "accent-2":    #e040fb,
  "accent-3":    #d500f9,
  "accent-4":    #aa00ff
);

$deep-purple: (
  "lighten-5":  #ede7f6,
  "lighten-4":  #d1c4e9,
  "lighten-3":  #b39ddb,
  "lighten-2":  #9575cd,
  "lighten-1":  #7e57c2,
  "base":       #673ab7,
  "darken-1":   #5e35b1,
  "darken-2":   #512da8,
  "darken-3":   #4527a0,
  "darken-4":   #311b92,
  "accent-1":    #b388ff,
  "accent-2":    #7c4dff,
  "accent-3":    #651fff,
  "accent-4":    #6200ea
);

$indigo: (
  "lighten-5":  #e8eaf6,
  "lighten-4":  #c5cae9,
  "lighten-3":  #9fa8da,
  "lighten-2":  #7986cb,
  "lighten-1":  #5c6bc0,
  "base":       #3f51b5,
  "darken-1":   #3949ab,
  "darken-2":   #303f9f,
  "darken-3":   #283593,
  "darken-4":   #1a237e,
  "accent-1":    #8c9eff,
  "accent-2":    #536dfe,
  "accent-3":    #3d5afe,
  "accent-4":    #304ffe
);

$blue: (
  "lighten-5":  #E3F2FD,
  "lighten-4":  #BBDEFB,
  "lighten-3":  #90CAF9,
  "lighten-2":  #64B5F6,
  "lighten-1":  #42A5F5,
  "base":       #2196F3,
  "darken-1":   #1E88E5,
  "darken-2":   #1976D2,
  "darken-3":   #1565C0,
  "darken-4":   #0D47A1,
  "accent-1":    #82B1FF,
  "accent-2":    #448AFF,
  "accent-3":    #2979FF,
  "accent-4":    #2962FF
);

$light-blue: (
  "lighten-5":  #e1f5fe,
  "lighten-4":  #b3e5fc,
  "lighten-3":  #81d4fa,
  "lighten-2":  #4fc3f7,
  "lighten-1":  #29b6f6,
  "base":       #03a9f4,
  "darken-1":   #039be5,
  "darken-2":   #0288d1,
  "darken-3":   #0277bd,
  "darken-4":   #01579b,
  "accent-1":    #80d8ff,
  "accent-2":    #40c4ff,
  "accent-3":    #00b0ff,
  "accent-4":    #0091ea
);

$cyan: (
  "lighten-5":  #e0f7fa,
  "lighten-4":  #b2ebf2,
  "lighten-3":  #80deea,
  "lighten-2":  #4dd0e1,
  "lighten-1":  #26c6da,
  "base":       #00bcd4,
  "darken-1":   #00acc1,
  "darken-2":   #0097a7,
  "darken-3":   #00838f,
  "darken-4":   #006064,
  "accent-1":    #84ffff,
  "accent-2":    #18ffff,
  "accent-3":    #00e5ff,
  "accent-4":    #00b8d4
);

$teal: (
  "lighten-5":  #e0f2f1,
  "lighten-4":  #b2dfdb,
  "lighten-3":  #80cbc4,
  "lighten-2":  #4db6ac,
  "lighten-1":  #26a69a,
  "base":       #009688,
  "darken-1":   #00897b,
  "darken-2":   #00796b,
  "darken-3":   #00695c,
  "darken-4":   #004d40,
  "accent-1":    #a7ffeb,
  "accent-2":    #64ffda,
  "accent-3":    #1de9b6,
  "accent-4":    #00bfa5
);

$green: (
  "lighten-5":  #E8F5E9,
  "lighten-4":  #C8E6C9,
  "lighten-3":  #A5D6A7,
  "lighten-2":  #81C784,
  "lighten-1":  #66BB6A,
  "base":       #4CAF50,
  "darken-1":   #43A047,
  "darken-2":   #388E3C,
  "darken-3":   #2E7D32,
  "darken-4":   #1B5E20,
  "accent-1":    #B9F6CA,
  "accent-2":    #69F0AE,
  "accent-3":    #00E676,
  "accent-4":    #00C853
);

$light-green: (
  "lighten-5":  #f1f8e9,
  "lighten-4":  #dcedc8,
  "lighten-3":  #c5e1a5,
  "lighten-2":  #aed581,
  "lighten-1":  #9ccc65,
  "base":       #8bc34a,
  "darken-1":   #7cb342,
  "darken-2":   #689f38,
  "darken-3":   #558b2f,
  "darken-4":   #33691e,
  "accent-1":    #ccff90,
  "accent-2":    #b2ff59,
  "accent-3":    #76ff03,
  "accent-4":    #64dd17
);

$lime: (
  "lighten-5":  #f9fbe7,
  "lighten-4":  #f0f4c3,
  "lighten-3":  #e6ee9c,
  "lighten-2":  #dce775,
  "lighten-1":  #d4e157,
  "base":       #cddc39,
  "darken-1":   #c0ca33,
  "darken-2":   #afb42b,
  "darken-3":   #9e9d24,
  "darken-4":   #827717,
  "accent-1":    #f4ff81,
  "accent-2":    #eeff41,
  "accent-3":    #c6ff00,
  "accent-4":    #aeea00
);

$yellow: (
  "lighten-5":  #fffde7,
  "lighten-4":  #fff9c4,
  "lighten-3":  #fff59d,
  "lighten-2":  #fff176,
  "lighten-1":  #ffee58,
  "base":       #ffeb3b,
  "darken-1":   #fdd835,
  "darken-2":   #fbc02d,
  "darken-3":   #f9a825,
  "darken-4":   #f57f17,
  "accent-1":    #ffff8d,
  "accent-2":    #ffff00,
  "accent-3":    #ffea00,
  "accent-4":    #ffd600
);

$amber: (
  "lighten-5":  #fff8e1,
  "lighten-4":  #ffecb3,
  "lighten-3":  #ffe082,
  "lighten-2":  #ffd54f,
  "lighten-1":  #ffca28,
  "base":       #ffc107,
  "darken-1":   #ffb300,
  "darken-2":   #ffa000,
  "darken-3":   #ff8f00,
  "darken-4":   #ff6f00,
  "accent-1":    #ffe57f,
  "accent-2":    #ffd740,
  "accent-3":    #ffc400,
  "accent-4":    #ffab00
);

$orange: (
  "lighten-5":  #fff3e0,
  "lighten-4":  #ffe0b2,
  "lighten-3":  #ffcc80,
  "lighten-2":  #ffb74d,
  "lighten-1":  #ffa726,
  "base":       #ff9800,
  "darken-1":   #fb8c00,
  "darken-2":   #f57c00,
  "darken-3":   #ef6c00,
  "darken-4":   #e65100,
  "accent-1":    #ffd180,
  "accent-2":    #ffab40,
  "accent-3":    #ff9100,
  "accent-4":    #ff6d00
);

$deep-orange: (
  "lighten-5":  #fbe9e7,
  "lighten-4":  #ffccbc,
  "lighten-3":  #ffab91,
  "lighten-2":  #ff8a65,
  "lighten-1":  #ff7043,
  "base":       #ff5722,
  "darken-1":   #f4511e,
  "darken-2":   #e64a19,
  "darken-3":   #d84315,
  "darken-4":   #bf360c,
  "accent-1":    #ff9e80,
  "accent-2":    #ff6e40,
  "accent-3":    #ff3d00,
  "accent-4":    #dd2c00
);

$brown: (
  "lighten-5":  #efebe9,
  "lighten-4":  #d7ccc8,
  "lighten-3":  #bcaaa4,
  "lighten-2":  #a1887f,
  "lighten-1":  #8d6e63,
  "base":       #795548,
  "darken-1":   #6d4c41,
  "darken-2":   #5d4037,
  "darken-3":   #4e342e,
  "darken-4":   #3e2723
);

$blue-grey: (
  "lighten-5":  #eceff1,
  "lighten-4":  #cfd8dc,
  "lighten-3":  #b0bec5,
  "lighten-2":  #90a4ae,
  "lighten-1":  #78909c,
  "base":       #607d8b,
  "darken-1":   #546e7a,
  "darken-2":   #455a64,
  "darken-3":   #37474f,
  "darken-4":   #263238
);

$grey: (
  "lighten-5":  #fafafa,
  "lighten-4":  #f5f5f5,
  "lighten-3":  #eeeeee,
  "lighten-2":  #e0e0e0,
  "lighten-1":  #bdbdbd,
  "base":       #9e9e9e,
  "darken-1":   #757575,
  "darken-2":   #616161,
  "darken-3":   #424242,
  "darken-4":   #212121
);

$shades: (
  "black":      #000000,
  "white":      #FFFFFF
);

$colors: (
  "materialize-red": $materialize-red,
  "red": $red,
  "pink": $pink,
  "purple": $purple,
  "deep-purple": $deep-purple,
  "indigo": $indigo,
  "blue": $blue,
  "light-blue": $light-blue,
  "cyan": $cyan,
  "teal": $teal,
  "green": $green,
  "light-green": $light-green,
  "lime": $lime,
  "yellow": $yellow,
  "amber": $amber,
  "orange": $orange,
  "deep-orange": $deep-orange,
  "brown": $brown,
  "blue-grey": $blue-grey,
  "grey": $grey,
  "shades": $shades
);


// Color Classes

@each $color_name, $color in $colors {
  @each $color_type, $color_value in $color {
    @if $color_type == "base" {
      .#{$color_name} {
        background-color: $color_value !important;
      }
      .#{$color_name}-text {
        color: $color_value !important;
      }
    }
    @else {
      .#{$color_name}.#{$color_type} {
        background-color: $color_value !important;
      }      
      .#{$color_name}-text.#{$color_type} {
        color: $color_value !important;
      }
    }
  }
}

// Shade classes
@each $color, $color_value in $shades {
  .#{$color} {
    background-color: $color_value !important;
  }
  .#{$color}-text {
    color: $color_value !important;
  }
}


// usage: color("name_of_color", "type_of_color")
// to avoid to repeating map-get($colors, ...)

@function color($color, $type) {
  @if map-has-key($colors, $color) {
    $curr_color: map-get($colors, $color);
    @if map-has-key($curr_color, $type) {
      @return map-get($curr_color, $type);
    }
  }
  @warn "Unknown `#{name}` in $colors.";
  @return null;
}

Support for Xamarin Forms css syntax

Description

With the introduction of Xamarin Forms 3.0 css is now supported. While most of the css is generally valid css, there is a selector that is not typically supported for web applications. Having the ability to generate the css from Sass would be hugely beneficial but currently the Sass compiler generates an exception. I need a way that I can support compiling sass that uses the derived types syntax:

Selector Example Description
^base ^contentpage Selects all elements with ContentPage as base class, including ContentPage itself. Case irrelevant. This selector isn't present in the CSS specification, and only applies to XF.

Sample

As an example I might want to make all buttons have a transparent background whether I'm using the base Button class or some custom Button class.

^button {
  background-color: transparent;
}

Combining the two platform builds.

Hi there,

Have you considered embedding the two c++ binaries as a resource and delivering the correct one based on processor architecture on demand? That would save having to maintain two libraries and make it easier for people to consume the library.

w3wp.exe locks 'libsass*.dll'

Hi

After running the following code:

var compiler = new SassCompiler(new SassOptions { OutputStyle = SassOutputStyle.Compressed, InputPath = customScssPath });
var result = compiler.Compile();

The dll libsass* is locked, until we kill w3wp.exe

How can we release the resources?

With kind regards,

Jan van Helvoort

calc

The new calc attribute is not recognized
sass

Could not load file or assembly 'LibSass.x86.DLL' or one of its dependencies. The specified module could not be found.

I have an asp.net web project and have installed the following packages:

libsassnet v3.2.5.1
libsassnet.Web v2.1.3.1

I also have my bundles configured like so:
bundles.Add(new SassBundle("/bundles/sass/bootstrap").Include("/sass/bootstrap.scss"));

When I compile the project, I see that the LibSass.x86.dll is located in my bin folder, so I am unsure of why it's unable to load the assembly.

Why should implement huge Interface to use LibSass?

Hi,

In provided wiki, usage is really simple, the code snippet is as follow:

var sassCompiler = new SassCompiler();
var result =  sassCompiler.Compile("body { color:blue; }");

But in real world usage, we should implement ISassOptions interface in order to use this tool. is there any to avoid that?

libsass

Thanks!

Log output

I didn't find any console output with build information, or build problems. Can you specify place where i can get this info?

The type initializer threw an exception

In trying to use the alpha version of libsassnet (3.3.7-alpha-2), I am able to run the SASS compiler locally on my dev machine, but trying to execute it on the deployment server produces the following error:

The type initializer for 'LibSass.Compiler.SassCompiler' threw an exception.

I have installed the VC2013 x64 Runtime, and I even tried installing the VC2015 x64 Runtime. I'm assuming it is just some dependency that I missed installing, but I'm not seeing what it was. Any help would be appreciated! Thanks!

Compilation is crashing IIS

I've only just come by this project which look perfect, however IIS is throwing an error when I try to compile:

Unhandled exception at 0x00007FFD554FBEF0 (libsass64.dll) in w3wp.exe: Stack cookie instrumentation code detected a stack-based buffer overrun.

This is my test code, am I missing anything?
The usage wiki is a bit out of date.

var currentPath = Server.MapPath("/content/css");
var inputPath = Path.Combine(currentPath, "scss\\site.scss");
var includePaths = new List<string>
{
    Path.Combine(currentPath, "scss"),
    Path.Combine(currentPath, "scss\\library"),
    Path.Combine(currentPath, "scss\\plugins")
};

var sassOptions = new SassOptions
{
    InputPath = inputPath,
    IncludePaths = includePaths.ToArray(),
    OutputStyle = SassOutputStyle.Compact
};
var sassCompiler = new SassCompiler(sassOptions);
var sassResult = sassCompiler.Compile();

var cssString = sassResult.Output;

image

SASSHandler output is empty

Goodday,

I am excited to use this product but when I use it outside of visual studio, it fails.

  • the the scss file served up is empty (0k).
  • If I remove the handler it serves up a 404, so it is using the handler.
  • The file compiles fine in visual studio.
  • When put in IIS (even on the same machine, with the same dependencies) the file is empty.

Heap Corruption error on Compile

If i use new SassCompiler().Compile(scssContent);
i get an exception that the heap might be corrupted
If i write my scssContent to a file and then use the CompileFile function it works flawlessly.
Do you have an Idea what could be causing this?

Support for .NET Standard

Most packages are going the way of .NET Standard, if they can, and it would allow for better support for ASP.NET Core projects.

Takes minutes to compile

Using latest stable build 2.1.3.1:

Every reload of the webpage uses an enormous amount of time on the .scss files. A 300 line file takes 3-10 second (varies videly), and bootstrap takes several minutes.

Bootstrap uses around 1.1 minute, (comparably, it takes around 1.5 seconds with LESS and dotless)

image

SassCompiler.Compile crashes

My app crashes every time I try to compile anything with SassCompiler.Compile (CompileFile works fine).

Here is what I get when I pass "body{}" as an input string into Compile:
image

Just tried with the latest LibSass - still the same problem.

Some thoughts on the future Native binding

In the forthcoming release of libsass (v3.3.0), the structure of .vcxproj file that resides in the upstream has changed: sass/libsass#1439. It now produces a .dll and .lib (it used to produce sassc.exe, which is now refactored to sassc repo where .exe belongs: sass/sassc#132).

What this mean for libsass-net is there are (at least) two approaches that can be taken for enhancement:

  1. Restructure the libsass-net/libsass/LibSass.vcxproj by removing all the native/* compile targets in favour of <import> native/win/libsass.targets.
    • I have not figure out yet how to specify CompileAsManaged=false for entire group of sources, imported by .targets in git submodule scenario (i.e. without modifying .targets itself).
    • Benefit: separation of concern - libsass-net will not have to update binding layer for each release of libsass unless there are interface/API breaking changes, which seldom happen.
  2. Use shim approach taken by dotnet/corefx team and ditch C++/CLI binding all together and use DllImport[] directive in C#, to import the upstream functions and properties to be consumed. This means the native/win/libsass.vcxproj will be build as part of the build step (<Exec>'ing out the MSBuild task directly in .csproj file) or added to libsass-net solution directly and then DllImport'd in C# code without intermediate binding LibSass.vcxproj.
    • Benefits: in addition to the aforementioned benefits, libsass-net will be able to target Unix platforms via Mono (libsass.so is already distributed and build on many Unices). This may also provide significant performance boost (#25).

Note (for option 2): (as mentioned in the Goals section) with shim approach the inherent benefit is; the ABI varies for each platform (libc for example), but the API will remain consistent for most part. This is aligned with what @mgreter and @QuLogic envisioned for libsass' new C API: sass/libsass#631.

How to use with Bundle Transformer?

I have a test file but its not comping....
see four.scss
when i view source its still not compiled

//Global CSS Scripts
bundles.Add(new StyleBundle("~/x/turbo/global.css", (@AppState["CDN"] + "/x/" + AppState["siteVersion"].ToString() + "/turbo/global.css"))
    .Include(
    "~/x/s/g/css/one.css",
    "~/x/s/g/css/two.css",
    "~/x/s/g/css/three.css",
    "~/x/s/g/css/four.scss"
    )
);

Error: File to read not found or unreadable

Hi,

I am trying to read a SASS file from a network location and it is throwing the following error:

"Error: File to read not found or unreadable: \\PATH\TO\SASS\FOLDER\SASS.scss\n"

I am using the following configurations:

var sassCompiler = new SassCompiler();
var scss = sassCompiler.CompileFile(targetScssFile, OutputStyle.Compact);

I have tried using the same code on a local folder (D:\PATH\TO\SASS) and it works perfectly well.

Please could you give me any pointers / try and test this from your end and let me know the results.

Thanks.

Large project performance

I am contemplating replacing a node based build process with libsass-net, however am seeing some strange performance issues.

For example, to build bootstrap can sometimes take 20+ seconds with libsass-net whereas node-sass does this in a consistent 1.5s.

One thing I did notice is that compile times can vary between 12s and 20s for libsass-net so maybe it's just a setting I have which is forcing more IO?

An example repo is here, with both node and c# runners: https://github.com/amar-tcpl/libsass-perf

Update libsass-net to latest libsass (3.1)

Hi Darren,

Really appreciate the work you have done on libsass-net. It has been a life saver in our project.

But as of late I can no longer get it to work with the latest libsass master. Would you be able to give me some hints into how I would get this to run?

We would love to update libsass to 3.1 with the new sass functionalities that come with it.

Cheers,
_Rj

ExecutionEngineException

Hello,

I'm currently using LibsassNet & web and from on random occasions i see that an Unknown error occurred is thrown in the C# part of the project, and the scss isn't compiled, however if i refresh the page it's all ok again and after few more refreshes it's broken.

Unfortunately i was not able to find a reliable way to reproduce this
However i did some debugging on the C++ project and it throws this exception on line 93
int result = sass_compile_file(ctx); in SassInterface.cpp

Any help with this issue, because i'm looking to use this library in production website in few months.

Processor Architecture warning

Hi,

I've been trying to get this library working via another project which consumes it (https://github.com/JimBobSquarePants/Cruncher), but it fails at runtime and the following warning is reported in Visual Studio 2012:

Warning There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "libsassnet, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

More detials on the runtime error are reported here JimBobSquarePants/Cruncher#28

Alpha version use recommendation in readme

On 2016-10-28, the README was updated to state that users should use the alpha versions (3.3.7-alpha-2) and that the stable versions are not ready for use. On 2016-11-22, 3.3.7 stable was pushed to nuget. Could the README be updated to clarify which specific versions are recommended for use in light of this, and if the stable 3.3.7 push is recommended for production use or if the alpha recommendation was expected to still apply.

System.Runtime.InteropServices.COMException

Hello, it's my action in asp.net mvc:

string scss = @"@import """ + Server.MapPath(scssPath) + @""";";
var compiler = new SassCompiler();
//string compiled = compiler.Compile(source: scss); //returns "button.button {background-color:#ffffff;}button.button:hover {opacity:0.5;}"
var compiled = compiler.Compile(scss);

I have the error
An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code

Additional information: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

What can be reason for it?

3.2.4.1 broke source maps

The latest release broke the source map generation. CompileFileResult.SourceMap is null after running the compiler with either an absolute or relative path parameter for the source map file

Compile multiple files and change variable by coding

Hi all,

Can we change a variable and also combine all sass files into one and then generate a file css file ?

For example I want to change @body-color that depending on my setting in database and a css file should be generated base on that color.

Thanks

Current version of Libsass-net throw a nullreference exception while runtime compiling on Azure web server

Hello, in the web application with which I'm working we are using Libsass-net for compiling some .scss on runtime, substituting some colour variables in the process.

The weird thing is that locally everything seems to work fine (even if sometimes the error occurs), while when publishing on an azure web server, the compiling works just one or two times fine, after that the sassCompiler.Compile() starts to throw nullreferenceexceptions.

the error trace is the sequent:

System.NullReferenceException: at LibSass.Compiler.SassExterns64.sass_compile_file_context (LibSass.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null) at LibSass.Compiler.Context.SassSafeFileContextHandle.CompileInternalContext (LibSass.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null) at LibSass.Compiler.Context.SassSafeContextHandle.CompileContext (LibSass.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null)

while the code and the sobstitution that im using is the sequent:

private static CustomImportDelegate _customImportDelegate;
private SassImport[] SassImportDelegate(string currentImport, string parentImport, ISassOptions sassOptions)
        {
                var sassImport = new List<SassImport>();
                var variablesImport = new SassImport();

                if (currentImport.EndsWith("_variables_00_backend"))
                {
                    variablesImport.Data = _colorString;
                }
                else
                {
                    variablesImport.Path = currentImport;
                }
                sassImport.Add(variablesImport);
                return sassImport.ToArray();
            
        }

private string GenerateCss(string path)
        {
                _customImportDelegate = SassImportDelegate;
                Telemetrytrace($"path is {path}");
                var sassOptions = new SassOptions
                {
                    InputPath = HttpContext.Current.Server.MapPath(path),
                    Importers = new[]{ _customImportDelegate },
                    IncludeSourceComments = false,
                    OutputStyle = SassOutputStyle.Compressed,              
                };

                var sassCompiler = new SassCompiler(sassOptions);
                var sassResult = sassCompiler.Compile();
                return sassResult.Output;   
        }

Is there anyone that had the same problem? any solution out there?

thanks in advance! cheers.

The handle is invalid

Just upgraded to v3.2.4 and am now getting the following error.

The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

Thrown on.

ISassCompiler.Compile();

Not sure what else you'll need from me.

System.AccessViolationException When Referenced Variable Missing

I found an issue when compiling from a content string and global variable is not declared.

Here is the invalid scrubbed input string:

$color-primary :#339999;
$color-secondary :#000000;
@import "C:\Source Code\svn\DEV\Web\css\scss\styles.scss"

Here is the valid scrubbed input string:

$color-primary :#339999;
$color-secondary :#000000;
$logo-path :'http://localhost/Images/image.jpg';
@import "C:\Source Code\svn\DEV\Web\css\scss\styles.scss"

Here is the code used to execute the string:

using (SassCompiler compiler = new SassCompiler())
{
    CompilationOptions options = new CompilationOptions
    {
        IncludePaths = new List<string> {scssSourceDirectory},
        OutputStyle = OutputStyle.Compressed
    };

    CompilationResult results = compiler.Compile(content, null, null, options);
    css = results.CompiledContent;
}

Here is the exception:

System.AccessViolationException was caught
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=LibSassHost.Native-Proxy
  StackTrace:
       at LibSassHost.Native.Helpers.MarshallingHelper.custom_strdup(SByte* value)
       at LibSassHost.Native.Helpers.MarshallingHelper.UnmarshalConstString(SByte* value)
       at LibSassHost.Native.SassNativeCompiler.FillManagedContextError(SassContext context, Sass_Context* ctx)
       at LibSassHost.Native.SassNativeCompiler.Compile(SassDataContext dataContext)
       at LibSassHost.SassCompiler.Compile(String content, String inputPath, String outputPath, CompilationOptions options)...

Intermittent NullReferenceExceptions

Hi!

I'm using libsass-net to compile a top level SCSS file which imports about 20 ancestor files (code attached). I'm seeing intermittent NullReferenceExceptions maybe once every 5-10 compilations and the point of failure varies (i.e. the import after which it dies). Here's the stack trace:

System.NullReferenceException: Object reference not set to an instance of an object.
at LibSass.Compiler.SassExterns64.sass_compile_data_context(SassSafeDataContextHandle data_context)
at LibSass.Compiler.Context.SassSafeDataContextHandle.CompileInternalContext()
at LibSass.Compiler.Context.SassSafeContextHandle.CompileContext()

Given this, I assume it's something going wrong inside libsass itself. I can reliably reproduce this by periodically making requests to our endpoint which compiles that top level file. I would guess that it's unrelated to concurrency as I'm waiting a few seconds in between. However, it's quite possible that libsass is being dodgy and sharing some state between compilations.

I attempted to debug it and track it down by building libsass 3.3.6 from source with logging statements attached. Didn't have much luck though. This is possibly the same issue as #60.

I haven't lodged a bug report with libsass as I'm unsure whether it's still a bug in their latest version. How much effort do you think would be required to bring libsass-net up to date so that it works with 3.5.4? I might end up giving it a shot.

var compilerOptions = new SassOptions
{
Data = topLevelScss,
EmbedSourceMap = true,
OutputStyle = SassOutputStyle.Expanded,
Importers = new[] { BuildImportResolver(scssResources) },
};

var sassCompiler = new SassCompiler(compilerOptions);
var compilationResult = sassCompiler.Compile();

Proposal: Change the way of building native binaries

Currently we are compiling both x64 and x86 libsass binaries (solution) build.

This needs to change in such a way that we compile only one binary for the given set of configuration with constant name (libsass) and avoid copying binaries around.

This will help us when we build against other platform such as Linux and OSX.

node-sass has also this way of compiling one binary per build.


@darrenkopp,

This is the first step towards .NET Core support.

NuGet packaging would be also easier for multiple operating system, as it requires the same name but create the OS+Arch specific directory. Note that there is a platform inheritance involved in latest NuGet packaging when dealing with native binaries. For instance, Alpine Linux x64 inherits Linux x64, which has a sibling Linux x86 and parent Linux, which has Unix as parent and OSX and FreeBSD etc. at sibling nodes. NuGet handles all this at restore time, if we follow the right convention to package the bins.

I have few ideas about packaging that I would like to try once we get there. :)

Thoughts?

virto E commerce

could not load file or assembly 'libsass.x64' or one of its dependencies. An attempt was made to load a program with an incorrect format...

this error pops up while running the store front which is deployed in windows Azure.

Can any body let me know what could be the reason?

error screen1

Kuber

Sass to Scss

For my project (SquishIt) we're looking to replace a Sass preprocessor using ironruby and a very old Sass implementation with your library.

If I am reading right, it looks like libsass now has the ability to convert the old-style Sass syntax into Scss before processing (see sass/libsass#16 (comment)). However its' driven by the file extension - if processing content directly you need to do the conversion yourself prior to compilation. I'm hoping that the way this conversion is done can be called externally - if so, I think the best way to get it done for our purposes would probably be an "ISassToScssConverter" inside libsass-net that calls the native function. This would allow us to use the same functionality as libsass, saving us from implementing our own conversion and keeping it up to date.

If something like this would work for you let me know - I can try to figure out how to get it done and submit as a pull request. But if you wouldn't want to include it, let me know so we can implement our own conversion in .net. Just putting this out there ahead of time because I don't want to end up taking a dependency on an "unofficial" version of libsass-net.

Thanks for all you've done here - it seems to be working well for SCSS and the performance is a lot better than what we were getting with IronRuby.

MSBuild Target

Random idea, but would it be possible to create an MSBuild target to allow compiling the Sass before hand? I've put something like this together for my work when using Less. Reduces the startup hit for websites, and allows build time verification of Sass.

SCSS Compilation runs very slowly in debug

I'm using VS 2013 Premium with the 64bit version of libsass-net.

When running outside the debugger the compilation of an scss file takes < 1 second, running within the debugger results in a compilation of around 10-20 seconds.

I don't suppose you have any thoughts on what the problem might be?

Kind regards

Ian

Support specifying precision

support passing a parameter on the SassContext object to pass to sass_context object that allows you to control the precision.

look into what the ranges supported by libsass is

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.