0

有没有办法防止 grunt-contrib-less 编译带有下划线的文件?

我有一组文件正在导入到主文件中。导入的文件带有下划线前缀,@import "_fileone"但因为我使用带有动态映射的 grunt,所以正在编译所有 .less 文件 - 而我只对主文件感兴趣。

4

3 回答 3

1

不确定这是否回答了您的问题,但是从 less.js 1.5 开始,如果您使用 @import 引用指令,这些文件将无法编译,但它们的引用(mixins 等)将可用于 less 文件。

来自 less.js 文档:

**Import Options**
Less offers several extensions to the CSS @import CSS at-rule to provide more flexibility over what you can do with external files.
Syntax: @import (keyword) "filename";

The following import directives have been implemented:

reference: use a Less file but do not output it
inline: include the source file in the output but do not process it
less: treat the file as a Less file, no matter what the file extension
css: treat the file as a CSS file, no matter what the file extension
once: only include the file once (this is default behavior)
multiple: include the file multiple times
于 2014-09-18T20:15:29.937 回答
0

您可以创建第二个 grunt 任务来处理此下划线文件,并选择不压缩、mangler 等。

您也可以在两个任务中将此下划线和正常分开,并最终查看两者

于 2014-08-18T20:36:00.647 回答
0

在您的较少任务中忽略以 _ 开头的文件

src: ['styles/*.less', '!styles/_*.less'],

这是正常的忽略方式,与LESS无关:)

于 2015-03-13T20:05:44.587 回答