使用 nodejs gulp 在 Less 中导入 .css 文件

Import .css file in Less using nodejs gulp

根据 this question 可以从 less v.1.4.0.
导入 css 文件 我尝试使用 gulp-less 任务,但它不起作用。
有任何方法可以像这样导入 css 文件:@import "../spritesheet.css"; with nodeJS gulp?

有几种方法可以将文件包含在 LESS 中,具体取决于您的需要,使用 @import ([keyword]) "filename"

允许的关键字是:

  • 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
  • optional: continue compiling when file is not found

Lesscss.org - Import Options

我不清楚你的用例是什么,但是如果你想在你的 LESS 文件中进一步使用 spritesheet.css 的内容(例如扩展你的 spritesheet 中定义的 类)您需要 (less) 关键字。

如果您只想将 spritesheet.css 的内容包含到您的输出文件中,而根本不想从 LESS 文件中访问它们,请坚持使用 (inline)