You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for importing from npm packages: @import (npm) ... #1965
I want to propose a new feature which would allow to import less/css files from inside npm packages using Node module resolution algorithm (e.g. searching package inside node_modules directory in the current directory and up the tree, see Node docs for more details).
The syntax I propose is:
@import (npm) ...
which naturally extends import options available today. I think it would be nice to have npm import option to be compatible with other options such as reference, inline and so on.
The motivation for this is simple — browserify+npm become more and more popular for developing browser applications in a modular fashion. I think it would be nice to have the same degree of modularity when writing stylesheets with less.
For the reference, there's already an implementation of @import (npm) .... I think having this in core would enable much more straightforward usage and will allow to keep this feature in sync with less development.
We've talked about this, I like the idea. For the sake of discussion and a working demo, see the following (these are out of date, but they still demonstrate the concept):
@lukeapage I would like to add support for bower as well. Should I create a similar PR or a plugin? If plugin, can you link to docs or an existing example?
As I said on the pull request id rather npm:// and bower:// as it is environment specific not less language specific. It also means plugins just need to handle the filename, not edit the parser behaviour.
@hojberg See related discussion in #1972. (I.e. most likely not in The Core but in a plugin when v2.0 comes out (if someone writes such plugin of course)).
Activity
jonschlinkert commentedon Apr 10, 2014
We've talked about this, I like the idea. For the sake of discussion and a working demo, see the following (these are out of date, but they still demonstrate the concept):
lukeapage commentedon Apr 11, 2014
I would welcome this being implemented as a plugin to begin with.
andreypopp commentedon Apr 11, 2014
@lukeapage does less have plugin API?
jfsiii commentedon Apr 23, 2014
@lukeapage I would like to add support for bower as well. Should I create a similar PR or a plugin? If plugin, can you link to docs or an existing example?
jfsiii commentedon Apr 23, 2014
@lukeapage nevermind, I found #1861
lukeapage commentedon May 4, 2014
As I said on the pull request id rather npm:// and bower:// as it is environment specific not less language specific. It also means plugins just need to handle the filename, not edit the parser behaviour.
lukeapage commentedon May 4, 2014
Also have a look at the 2.0 pull request.
hojberg commentedon Aug 26, 2014
and progress on this? Would really like this feature!
seven-phases-max commentedon Aug 26, 2014
@hojberg See related discussion in #1972. (I.e. most likely not in The Core but in a plugin when v2.0 comes out (if someone writes such plugin of course)).
seven-phases-max commentedon Oct 23, 2014
Closing as supported with https://github.com/less/less-plugin-npm-import now.