dotlesscss 不显示错误
我的 css 有问题,因为编译后没有样式添加到我的网站。
如何让 dotlesscss 显示错误?常规 .less 会向您显示一条非常方便的好消息。
There's something wrong with my css because no styles are being added to my website after compilation.
How do I get dotlesscss to show errors? Regular .less shows you a nice message that's very handy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 web.config 轻松完成此操作。在 dotless 配置部分中,添加以下内容:
logger="dotless.Core.Loggers.AspResponseLogger"
。这将使错误输出无点,而不是空白 css。我将以下内容作为示例。 (“...”代表 web.config 中现有的内容)。在我下面的示例中,缓存设置为 false。这对于调试目的很有用。正常情况下应该将其设置为 true。
You can do this very easily with web.config. In your dotless configuration section, add the following:
logger="dotless.Core.Loggers.AspResponseLogger"
. This will make dotless output the errors instead of blank css.I've included the following as an example. ("..." represents existing stuff in your web.config). In my example below cache is set to false. This is useful for debugging purposes. It should probably be set to true under normal circumstances.
我今天刚刚在我的 RequestReduce 项目中遇到了这个问题。我变得越来越空白 -> css 转换是因为存在解析错误,这些错误似乎正在进入以太坊。由于
此相关答案 以编程方式使用 .less 时如何输出错误? 我能够找到一个解决方案,可以将错误写入响应流。您必须创建一个从 dotless.Core.Loggers.ILogger 派生的 Logger:
您将其传递到发送到 EngineFactory 的配置中:
出于单元测试的目的,我想传递将写入错误的 HttpResponseBase。这就是我觉得事情变得丑陋的地方,通过一些令人讨厌的铸造来获得对我的记录器的引用:
我希望这可以帮助你。
I just faced this today in my RequestReduce project. I was getting blank less -> css transforms because there were parse errors that appeared to be going into the ether. Thanks to
this related answer How can I output errors when using .less programmatically? I was able to work out a solution where I could write the errors to the response stream. You have to create a Logger derriving from dotless.Core.Loggers.ILogger:
You pass this into the Configuration sent to the EngineFactory:
For unit testing purposes I wanted to pass in my HttpResponseBase that would write the error. This is where I felt things getting ugly with some nasty casting to get a reference to my logger:
I hope this helps you out.