简体   繁体   English

C#Sass编译器

[英]C# Sass Compiler

So I have a C# (asp.net) based dashboard for a proprietary content management system. 因此,我有一个基于C#(asp.net)的仪表板,用于专有内容管理系统。 One of the things that the dashboard allows is for the user to go in and add custom css/sass to their site. 仪表板允许的操作之一是让用户进入并将自定义CSS / SASS添加到其站点。 When they do this, my controller calls a program that compiles the sass using NSass.Core. 当他们这样做时,我的控制器将调用一个使用NSass.Core编译sass的程序。

Up until now, I have been using Foundation 5 as my responsive framework. 到目前为止,我一直在使用Foundation 5作为响应框架。 Yesterday when attempting to update my controller to allow for Foundation 6 compilation, it started throwing errors. 昨天,当尝试更新我的控制器以允许Foundation 6编译时,它开始引发错误。 The errors were occurring every time the compiler attempted to parse a sass map (associative array). 每次编译器尝试解析sass映射(关联数组)时,都会发生错误。

I started doing some research into the problem and found out that sass maps are a relatively new mechanic in sass and the last time Nsass was updated was three years ago, so I am assuming this is the problem. 我开始对该问题进行一些研究,发现sass映射是sass中相对较新的机制,而Nsass的上一次更新是在三年前,所以我假设这是问题所在。

Has anyone had similar experience? 有没有人有类似的经历? If so, what was your solution. 如果是这样,您的解决方案是什么。 If not, does anyone use anything else that would work for me? 如果没有,是否有人会使用对我有用的其他东西? I have tried installing a couple other packages, but started receiving various other errors such as libsassnet not being able to find the 32 bit dll. 我尝试安装几个其他软件包,但是开始收到各种其他错误,例如libsassnet无法找到32位dll。 Hopefully someone here can give me an answer that saves me some time. 希望这里有人可以给我答案,从而节省一些时间。

The errors I have received when using Nsass were all along the lines of "error reading values after primary" where primary is the first value in the first map the compiler comes across. 我在使用Nsass时收到的错误一直都是“ primary之后读取错误的值”,其中primary是编译器遇到的第一个映射中的第一个值。 When I take that map out, it just moves to the next one and gives the same error. 当我取出该地图时,它会移至下一张并给出相同的错误。

As far as narrowing my question down... I just want to know what other people are using out there to compile Sass in C# 至于缩小我的问题范围……我只想知道其他人正在使用什么在C#中编译Sass。

There is a nuget package: Bundle Transformer: Sass and SCSS is a provider for Bundle Transformer . 有一个nuget包: Bundle Transformer:Sass和SCSSBundle Transformer的提供者。 In turn, this is an extension of System.Web.Optimisation that could allow you to add code to your CMS to compile user generated SCSS into Css files. 反过来,这是System.Web.Optimisation的扩展,它可以允许您向CMS添加代码以将用户生成的SCSS编译为Css文件。

An example of this can be found in the Optimus package for the Umbraco CMS. 在Umbraco CMS的Optimus软件包中可以找到一个示例。 Looking through this code could give you a good basis for creating your own system. 浏览这段代码可以为您创建自己的系统提供良好的基础。 If you speak with the Author of the package (a really nice guy) he might be able to help you create your own targeted package that isn't dependent on Umbraco. 如果您与软件包的作者(一个非常好的人)交谈,他也许可以帮助您创建不依赖于Umbraco的目标软件包。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM