Import .css file in Less using nodejs gulp

一世执手 提交于 2019-12-21 10:10:15

问题


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?


回答1:


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

Allowed keywords are:

  • 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

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.

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



来源:https://stackoverflow.com/questions/29727449/import-css-file-in-less-using-nodejs-gulp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!