Skip to content

User-level extend for import syntax? #3056

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

Closed
thybzi opened this issue Apr 22, 2017 · 3 comments
Closed

User-level extend for import syntax? #3056

thybzi opened this issue Apr 22, 2017 · 3 comments

Comments

@thybzi
Copy link

thybzi commented Apr 22, 2017

Please tell me if LESS has any kind of API (or whatever) to extend import syntax (add one more option).

What I want in my project is the following:

@import (standalone) 'foo';

That should do the following:

@import 'foo__deps'; // if file exists
@import 'foo';

Of course, that seems to my some custom functionality, so I don't want to change less.js code itself, but make some kind of module or plugin.
Is that possible in any way?

Thank you in advance.

@seven-phases-max
Copy link
Member

seven-phases-max commented Apr 22, 2017

Please tell me if LESS has any kind of API (or whatever) to extend import syntax (add one more option).

Well, you can't change syntax (i.e. what's handled by the parser), however depending on what you actually need (and how you're going to handle it... plugin?) there might be some options. After all, if it's plugin you will have to handle all the selector elements on your own anyway, so in fact any tag (or whatever) there can serve as a keyword, i.e. extend(#foo.bar whatever) is valid Less syntax hence no problem to use whatever tag as an option - i.e. just like all in extend(#foo.bar all)).


@import 'foo__deps'; // if file exists

Again it depends on why you actually need that. When I see something like above I start to suspect something like this. Aside of that, why, for example, can't you just have an empty 'foo__deps' file there?

@calvinjuarez
Copy link
Member

You might look at a plugin like https://github.com/less/less-plugin-npm-import as an example of how a plugin affecting @import behavior might work.

@thybzi
Copy link
Author

thybzi commented Apr 23, 2017

Thank you for the example!
So, closing this issue now.

@thybzi thybzi closed this as completed Apr 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants