使用 nodejs gulp 在 Less 中导入 .css 文件 [英] Import .css file in Less using nodejs gulp

查看:34
本文介绍了使用 nodejs gulp 在 Less 中导入 .css 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

According to this question it's possible to import css file from less v.1.4.0.
I tried to use gulp-less task, and it's not working.
There's any way to import css file like this: @import "../spritesheet.css"; with nodeJS gulp?

推荐答案

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

There are several ways to include files in LESS, depending on what you need, using @import ([keyword]) "filename".

允许的关键字是:

  • 参考:使用 Less 文件但不输出它
  • 内联:在输出中包含源文件但不处理它
  • less:无论文件扩展名如何,都将文件视为 Less 文件
  • css:将文件视为 CSS 文件,无论文件扩展名是什么
  • 一次:只包含一次文件(这是默认行为)
  • multiple:多次包含文件
  • 可选:找不到文件时继续编译

Lesscss.org - 导入选项

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

It's not clear to me what your use case is, but if you want to use the contents of spritesheet.css further on in your LESS file (for example extending classes defined in your spritesheet) you need the (less) keyword.

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

If you just want to include the contents of spritesheet.css into your output file without accessing them from within the LESS file at all, stick with (inline).

这篇关于使用 nodejs gulp 在 Less 中导入 .css 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆