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

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

问题描述

根据此问题,可以从较少的v导入css文件.1.4.0。

我尝试使用 gulp-less 任务,但它不工作。

有任何方法import css file like this: @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?

推荐答案

使用 @import([keyword])filename,有几种方法可以根据需要在LESS中包括文件。

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

允许的关键字有:



  • 使用Less文件但不输出

  • inline:在输出中包含源文件,但不处理

  • 作为Less文件,无论文件扩展名是什么

  • css:将文件视为CSS文件,无论文件扩展名是什么

  • :仅包含文件一次(这是默认行为)

  • 多次:多次包含文件

  • 可选:在找不到文件时继续编译

  • 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 - 导入选项

我不清楚你的用例是什么,但如果你想使用 spritesheet.css 在你的LESS文件中(例如在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天全站免登陆