gpt4 book ai didi

c# - Dotless Parse 不会缩小回车

转载 作者:行者123 更新时间:2023-11-30 17:51:10 26 4
gpt4 key购买 nike

我得到了旧的Would you like to normalize line endings在我的 .less 文件上,不假思索地这样做了。

后来我意识到我的 CSS 并没有完全缩小。这是转换的过程方法

public void Process(BundleContext context, BundleResponse response)
{
response.Content = dotless.Core.Less.Parse(response.Content);
response.ContentType = "text/css";
}

BundleConfig.cs

bundles.Add(new Bundle("~/Less/css", new LessTransform(), new CssMinify())
.Include("~/Content/css/App.less"));

我在 Process 中放置了一个断点并复制了之前/之后的 CSS,发现 dotless 只是删除了 /r 而不是 /n

这是我的 css 文件的一个片段,显示了该行为

在无点解析之前

"/*\r\n\r\nApp.less\r\n

无点解析后

"/*\n\nApp.less\n

所以它在技术上是可行的,只是不是最佳的。我正在考虑返回并从文件中删除 /r/n 并仅用 /r 替换它们,但会喜欢不会导致行尾的解决方案每当我打开文件时,对话框都会缠着我。

更新:忘了我最近也升级了 dotless nuget 包

我的网络配置

<configSections>
<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
...
</configSections>
...
<httpHandlers>
<add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
...
<handlers>
<add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
</handlers>
...
<dotless minifyCss="true" />

最佳答案

这是一个给我适当缩小的结果的例子,与你目前的结果非常相似:

捆绑配置

BundleTable.EnableOptimizations = true; // I think is what's missing

var cssBundle = new StyleBundle("~/Content/css")
.Include("~/Content/site.less");

cssBundle.Transforms.Add(new LessTransform());
cssBundle.Transforms.Add(new CssMinify());

bundles.Add(cssBundle);

LessTransform

public void Process(BundleContext context, BundleResponse response)
{
response.Content = dotless.Core.Less.Parse(response.Content);
response.ContentType = "text/css";
}

没有 Web.config 部分。

关于c# - Dotless Parse 不会缩小回车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19868684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com