0

初始帖子:我将一个项目从我的服务器移回我的本地环境,现在 .less 文件将无法编译。

.kit 和 .js 编译良好。当我保存一个 .less 文件时,codekit 说“成功的代码包编译了 xy.less”,但它没有生成任何东西。

此外,如果我在 less 文件中写了一些垃圾,仍然会有成功消息。

所有 .less 文件都很好地显示在代码工具包窗口中,但似乎完全忽略了 less 文件

osx Mavericks,codekit 1.9.3

我将问题缩小到 .less 导入中的 @font-face 声明。我使用来自 myfonts.com 的 webfont 我添加了 myfonts.com css 声明,如下所示:

@import url('//hello.myfonts.net/count/xy');
@font-face {
font-family: 'Blabla';
src:    url('/webfonts/29DFBD_0_0.eot');
src:    url('/webfonts/29DFBD_0_0.eot?#iefix') format('embedded-opentype'),
        url('/webfonts/29DFBD_0_0.woff') format('woff'),
        url('/webfonts/29DFBD_0_0.ttf') format('truetype');
}

有问题的行是format('embedded-opentype')在我的 less 文件中包含此行的行,代码工具包停止编译,但发出一条成功消息。

如果我在第四行写Hello World :

@import url('//hello.myfonts.net/count/xy');
@font-face {
font-family: 'Blabla';
src:    url('/webfonts/29DFBD_0_0.eot'); Hello World
src:    url('/webfonts/29DFBD_0_0.eot?#iefix') format('embedded-opentype'),
        url('/webfonts/29DFBD_0_0.woff') format('woff'),
        url('/webfonts/29DFBD_0_0.ttf') format('truetype');
}

Codekit 向我抛出了一个错误。

但如果我写同样的,下面一行:

@import url('//hello.myfonts.net/count/xy');
@font-face {
font-family: 'Blabla';
src:    url('/webfonts/29DFBD_0_0.eot');
src:    url('/webfonts/29DFBD_0_0.eot?#iefix') format('embedded-opentype'), Hello World
        url('/webfonts/29DFBD_0_0.woff') format('woff'),
        url('/webfonts/29DFBD_0_0.ttf') format('truetype');
}

这会引发成功消息,并且编译的 .css 不会更改。

所以一定是这条线对吗?:src: url('/webfonts/29DFBD_0_0.eot?#iefix') format('embedded-opentype'),那有什么问题?

4

1 回答 1

3

与您的结论相反,我认为问题出在@importMyFonts 用于跟踪浏览量的声明,即:

/* @import must be at top of file, otherwise CSS will not work */
@import url("//hello.myfonts.net/count/1a2b3c");

在这里,CodeKit 中的 LESS 预处理器在处理缺少文件扩展名的 URL 时遇到了问题。修复方法是在括号中指明文件类型@import

@import (css) url("//hello.myfonts.net/count/1a2b3c");

[事实上,上面提到的 CSS 段对于显示webfont 不是必需的,没有它也可以正常工作(也不会阻塞 CodeKit)。省略它可能会违反许可证,因为如果不 ping MyFonts 的服务器,他们不知道您是否在 webfont 使用配额内。]

于 2014-05-23T23:36:58.690 回答