sass / libsass-net

A lightweight wrapper around libsass
MIT License
94 stars 35 forks source link

Compile multiple files and change variable by coding #38

Closed sonphnt closed 7 years ago

sonphnt commented 8 years ago

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

janzii commented 8 years ago

We do it something like this in our project:

c# code

string sass = "$color: #123456;\n"
+ "@import \"template\";";

var compiler = new LibSassNet.SassCompiler();
var css = compiler.Compile(sass, outputStyle: LibSassNet.OutputStyle.Nested, includeSourceComments: true, includePaths: new[] { Server.MapPath("~/Content/sass") });

_template.scss

body {
    background-color: $color;
}