Import .css file in Less using nodejs gulp(使用 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 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 nodejs gulp 在 Less 中导入 .css 文件


- addEventListener 在 IE 11 中不起作用 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01