問題描述
根據(jù)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 文件但不輸出它
- 內(nèi)聯(lián):在輸出中包含源文件但不處理它
- less:無論文件擴展名如何,都將文件視為 Less 文件
- css:將文件視為 CSS 文件,無論文件擴展名是什么
- 一次:只包含一次文件(這是默認行為)
- multiple:多次包含文件
- 可選:找不到文件時繼續(xù)編譯
Lesscss.org - 導入選項
我不清楚你的用例是什么,但如果你想在 LESS 文件中進一步使用 spritesheet.css
的內(nèi)容(例如擴展你的 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
的內(nèi)容包含到輸出文件中,而根本不從 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 文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!