grunt-contrib-less がアンダースコアを持つファイルをコンパイルするのを防ぐ方法はありますか?
メインファイルにインポートされている一連のファイルがあります。インポートされたファイルにはアンダースコア@import "_fileone"がプレフィックスとして付けられていますが、ダイナミック マッピングで grunt を使用しているため、すべての .less ファイルがコンパイルされていますが、メイン ファイルのみに関心があります。
grunt-contrib-less がアンダースコアを持つファイルをコンパイルするのを防ぐ方法はありますか?
メインファイルにインポートされている一連のファイルがあります。インポートされたファイルにはアンダースコア@import "_fileone"がプレフィックスとして付けられていますが、ダイナミック マッピングで grunt を使用しているため、すべての .less ファイルがコンパイルされていますが、メイン ファイルのみに関心があります。
これがあなたの質問に答えるかどうかはわかりませんが、less.js 1.5 の時点で @import 参照ディレクティブを使用すると、それらのファイルはコンパイルされませんが、それらの参照 (ミックスインなど) は 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
あなたのより少ないタスクでは、_で始まるファイルを無視します
src: ['styles/*.less', '!styles/_*.less'],
これは通常のうなり声を無視する方法であり、LESS とは何の関係もありません :)
圧縮なし、マングラーなどのオプションを使用して、このアンダースコア ファイルを処理する 2 番目の grunt タスクを作成できます。
このアンダースコアと法線を 2 つのタスクに分けて、最終的に両方を確認することもできます。