问题标签 [dotless]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1129 浏览

css - .less 文件和 .css 子文件

我想知道这个文件结构是如何完成的。

在此处输入图像描述

我知道如何使用dotless,但我不知道如何在.less 文件下生成编译文件。
任何想法?

编辑

我发现了这个问题

我有一个想法,如果我能够使用<DependentUpon>标签使每个 .css 文件都位于 .less 文件旁边,那么它就可以工作。

我一直在关注这个关于 dotless 的 教程

我认为解决方案可以在这里完成:

但我不知道如何..请帮忙!

编辑 2

我想我需要改变这个问题。
所以我的新问题是,“如何Exec在项目中使用命令自动包含生成的文件,并使这些生成的 .css 文件作为目标 .less 文件的子文件?”

编辑 3

嗯..我的问题可能会让其他人感到困惑..我在这篇文章中找到了这个视频,这就是我想要的。从.less 文件生成.css 文件,并将.css 文件作为.less 的子文件,并使其自动包含在项目中!但是使用 MSBuild .. 这可能吗?请帮忙!:-)

编辑最终

好的.. 在我阅读了文档并使用了这个扩展
之后 ,我意识到,我正在做上面的旧事情。
所以,我不需要做上面的那些事情,它都是使用网络必需品完成的..

所以我的问题的答案是,使用 Web Essentials。

0 投票
1 回答
640 浏览

c# - Dotless Parse 不会缩小回车

我得到了旧的,你想在我的 .less 文件上规范化行尾,并且不假思索地这样做了。

后来我意识到我的 css 没有完全缩小。下面是变换的处理方法

BundleConfig.cs

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

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

无点解析之前

无点解析后

所以它在技术上是有效的,只是不是最优的。我正在考虑返回并/r/n从文件中删除并将它们替换为 just/r但我会喜欢一个不会​​导致行尾对话框在我打开文件时困扰我的解决方案。

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

我的网络配置

0 投票
1 回答
996 浏览

c# - Empty Bundle using MS Bundling

I am using asp.net mvc4 and the built in bundling and minification that is provided by MS using the System.Web.Optimization library (1.1.0) with a custom LessTransform using dotless. The site is hosted in IIS 7. My problem is that intermittently the bundle is empty on the website which causes the website to load all weird.

What could cause this?

UPDATE

  1. I read that if the less compiler encounters an error it could result in an empty bundle. I've tested the less for errors and there are none.

  2. I discovered that there maybe an issue with the way that the bundle was configured to use the Content directory, so I changed it from:

    /li>

to:

After redeploying the application, it appeared to resolve the issue. However, it's happening again. The setup is a load balancer that with 2 IIS servers. Today, I logged onto server 1 and browsed the site via IIS and it's loading fine.

Logging onto server 2 and browsing the site via IIS gives the bundling issue.

Update 2

To test the thought that the resource might be in use. I tried deleting the less files that were part of the bundle that caused the issue. The less files were successfully deleted. Upon restoring the .less files, the issue went away when browsing directly to the server.

Update 3

This issue just started cropping up on the dev server which is not load balanced with a bundle that is not using dotless

This was caused because of a nuget package upgrade and a file no longer being in the location it was referenced. I double checked all of the other bundles to make sure the files still existed where they were referenced and they do, so that's not the issue.

Update 4

Added logging to the dotless configuration and received this message:

Thoughts?

0 投票
1 回答
643 浏览

asp.net - 无点中 url() 中的应用程序相对路径

我有一堆包含图像背景的 .less 文件:

在调试模式下,这些 .less 文件直接提供,但在发布模式下,它们作为包的一部分提供。捆绑 URL 和单个文件 URL 之间的路径深度并不总是相同,所以我不能只使用相对 URL。

无点 nuget 包的默认选项不解析应用程序相对路径。有没有办法让它做正确的事?

0 投票
3 回答
3043 浏览

css - 两次导入相同的较少文件时出现 Dotless MVC 捆绑问题

我试图使用无点来完成以下结构:

styles/variables.less - 包含所有变量,如下所示



styles/component1.less - 一些随机的组件特定样式,它导入 variables.less



styles/component2.less - 更多样式,它们也导入全局 variables.less 文件



BundleConfig.cs - 像下面这样声明包。我使用这个捆绑添加:https ://gist.github.com/benfoster/3924025



当Debug设置为true 时一切正常

当 debug 设置为 true 时工作

但是当Debug设置为false

只有在 bundle 的 Include 方法中传递的第一个文件才能解析 @import "variables"。其余的只是失败。

下面是先声明“~/styles/component1.less”的输出


当首先声明 component1.less

首先声明“~/styles/component2.less”时的输出

当首先声明 componenet2.less

奇怪的是 - 如果我在 component1 和 component2 中导入不同的文件,它会起作用

例如,如果我在任一文件中将“varibales”重命名为“variables.less”,只是为了让这些导入看起来有点不同。有用。像下面

样式/component1.less

作品

有什么想法吗?这几天我一直在摆弄这个..

编辑

使用这种结构的原因:

  • 在调试模式下发送单独的更少文件,因为它更容易调试。行号注释不是很有帮助

  • 在生产环境中连接和缩小所有较少的文件。

在每个文件的顶部添加 @import "variables" 是丑陋的。

因此,尝试将 variables.less 声明为 .Include("variables.less", file-dependant-on-variables.less, ...) 的一部分,由于此处提到的一些范围问题,这显然不起作用:Dotless - Can't使用 MVC 捆绑在单独的文件中引用较少的变量

有一个解决方法,连接每个 less 文件的内容,并使用 Less 来解析连接的文件。这里的例子,https://groups.google.com/forum/?fromgroups#!topic/dotless/j-8OP1dNjUY

但在那种情况下,我似乎无法获得解析文件的缩小版本。

0 投票
0 回答
245 浏览

.net - dotless 无法随机构建 CSS

我无法跟踪为什么 dotless 无法构建样式表的原因。我们有 8 台负载平衡服务器。

在某些时候,用户会访问该站点并且样式表将无法编译,从而产生一个空白页面。我无法从错误日志中获取有关失败原因的任何信息。一旦编译失败,它们将无法再次工作,需要重新启动。

我们正在使用查询字符串参数,以便我们的 url 看起来像:

这个字符串在网站上填充得很好。Dotless 用于捕获这些参数,因此我们的 less 看起来像:

该站点会很好,然后突然无法正常工作。在我们的开发环境中,我们从未见过这种失败。但是,一旦它以较重的流量启动,它就开始频繁失败。

有人见过这样的吗?它在我们所有的服务器上都是一致的,所以这绝对是代码无法编译的问题。

<dotless />我对我的条目做了两件事web.config,似乎暂时解决了这个问题,但我认为这是次优的。我做了minifyCSS="true"(我们因为其他原因关闭了它)并设置了cache="false".

我相信关闭缓存web.config有助于防止上述问题,但对性能有害。

0 投票
2 回答
1779 浏览

c# - 无法在 C# 中使用 dotless 来使用 Less.Parse

我正在按照使用 .less来缩小 CSS 的说明进行操作。

我已经包含了 dll 并进行了Web.config更改。

index.cshtml但是,当我在as中引用它时Less.ParseLess命名空间不可用,并且出现异常“该名称Less在当前上下文中不存在”。

我错过了什么?

0 投票
1 回答
433 浏览

logging - 从 web.config 配置的 DotLess 自定义记录器

我通过实现 dotless.Core.Loggers.ILogger 接口创建了一个自定义记录器。

现在我尝试通过在 web.config 中配置它来使用这个记录器,如下所示:

问题是:没有写入任何跟踪,并且从未调用/创建我的自定义记录器。

如果我将记录器更改为像 ResponseLogger 这样的标准记录器之一:

我按预期在响应中收到一条日志消息。

自定义记录器的代码只是将记录转发到我们自己的跟踪器:

我究竟做错了什么?

(我已经在 DotLess google 群里发过了,但是两天没有得到任何回复,我决定交叉发布这个,希望没关系)

0 投票
1 回答
271 浏览

css - 使用 .less 文件将引导程序 2.3 迁移到 3.0

我们目前在超过 400 个 html 文件的应用程序中运行 bootstrap 2.3。我们决定在不更改所有 html 文件的情况下升级到 twitter bootstrap 3.0 的最佳方法是包含一个 .less 文件,该文件引用从 2.3 到 3.0 的所有更改。例如:3.0 中的 span6 现在是 col-md-6。是否有人拥有将所有旧属性嵌入到我们可以引用的 .less 文件中的文件?

0 投票
2 回答
850 浏览

css - 在@import 语句中使用变量 - DotLess

我正在使用 DotLess v1.4,我想做以下事情:

当我这样做时,我得到一个找不到文件的错误。

解析时未找到文件:您正在导入无法找到的以 .less 结尾的文件。

如果我这样做,它可以正常工作。

据我所知,这是在 1.4 版中添加到 Less 中的,所以我认为它可以在最新版本的 DotLess 中使用。

有谁知道这个功能是否可用,如果可以,我做错了什么?