Skip to content
treefishuk edited this page Oct 5, 2016 · 3 revisions

Basic usage

Using LibSass-net is fairly easy and the most basic setup is composed of 2 steps

  1. Installation Simply execute this command in your package management console:
Install-Package libsassnet.Web

the instalation will take care of adding .scss http handler to you Web.config

  1. Adding a bundle
 bundles.Add(new SassBundle("~/Content/css").Include(
           "~/sass/site.scss"));

Advanced usage

  1. Installation Simply execute this command in your package management console:
Install-Package libsassnet

Compiling a file

var sassCompiler = new SassCompiler();

var compact = sassCompiler.CompileFile(@"C:\<path to scss file>\Site.scss", OutputStyle.Compact);

System.IO.File.WriteAllText(@"C:\compact.css", compact.CSS);

Compiling a string

var sassCompiler = new SassCompiler();

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

System.IO.File.WriteAllText(@"C:\compact.css", result);

Available output styles

  • OutputStyle.Nested
  • OutputStyle.Expanded
  • OutputStyle.Compact
  • OutputStyle.Compressed
  • OutputStyle.Echo
Clone this wiki locally