2015-04-19 26 views
8

根據this question可以從少於v.1.4.0導入css文件。
我試圖使用gulp-less任務,它不工作。
有什麼辦法可以像這樣導入css文件:@import "../spritesheet.css"; with nodeJS gulp?用less導入.css文件使用nodejs gulp

+0

定義「它不工作」?你試圖完全實現的是什麼?你需要訪問.css文件中定義的類以便在.less文件中重用嗎? –

+0

events.js:72 throw er; //未處理「錯誤」事件 ^ 錯誤:損壞「../spritesheet.css」的@import聲明 – cheziHoyzer

回答

6

有幾種方法可以使用@import ([keyword]) "filename"以LESS包含文件,具體取決於您的需要。

允許的關鍵字是:

  • 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)

+0

@import(inline)是答案!謝謝!! – cheziHoyzer