Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for importing from npm packages: @import (npm) ... #1965

Closed
andreypopp opened this issue Apr 10, 2014 · 10 comments
Closed

Support for importing from npm packages: @import (npm) ... #1965

andreypopp opened this issue Apr 10, 2014 · 10 comments

Comments

@andreypopp
Copy link

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.

@jonschlinkert
Copy link
Contributor

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
Copy link
Member

I would welcome this being implemented as a plugin to begin with.

@andreypopp
Copy link
Author

@lukeapage does less have plugin API?

@jfsiii
Copy link

jfsiii commented 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
Copy link

jfsiii commented Apr 23, 2014

@lukeapage nevermind, I found #1861

@lukeapage
Copy link
Member

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
Copy link
Member

Also have a look at the 2.0 pull request.

@hojberg
Copy link

hojberg commented Aug 26, 2014

and progress on this? Would really like this feature!

@seven-phases-max
Copy link
Member

@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
Copy link
Member

Closing as supported with https://github.com/less/less-plugin-npm-import now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants