are any alternatives for compile .scss files in action in ASP.NET MVC controller?
I have /Content folder with two files: main.scss and external.scss. In my controller I'm using NSASS package:
public ActionResult GetCss(string scssPath)
{
string scss = @"@import """ + Server.MapPath(scssPath) + @""";";
var compiler = new SassCompiler();
string compiled = compiler.Compile(source: scss);
return Content(compiled.ToString(), "text/css");
}
my view:
<link href="@Url.Action("GetCss", "Theme", new { scssPath="~/Content/sass/main.scss" })" rel="stylesheet" type="text/css" />
main.scss file:
@import "external";
I have error
Error: File to import not found or unreadable: external
I tried to write @import "external.scss" but same problem.
NSass is outdated. It was updated last time in 2013 and can't compile many new scss syntaxes, but if you want to compile few simple lines and have rest precompiled, here's simplest solution I came up with.
Btw, if you would like to import other scss files into your main scss file, you can use following code but note I'm not good at Regex and thins it might have flaws.