less.js icon indicating copy to clipboard operation
less.js copied to clipboard

Support '*' wildcard for @import

Open luk3thomas opened this issue 13 years ago • 12 comments

It would be nice if less.js supported wildcards for the @import function. For example:

Directory structure:

.
├── main.less
└── some
    └── dir
        ├── a.less
        ├── b.less
        └── c.less

Then in main.less I can import all the files inside some/dir:

@import 'some/dir/*'

If this feature is relevant and worth considering I'm happy to submit a PR. Let me know what you think. Thanks!

luk3thomas avatar Jul 25 '13 15:07 luk3thomas

duplicate of https://github.com/less/less.js/issues/1181

jonschlinkert avatar Jul 25 '13 15:07 jonschlinkert

P.s a pr would be great.. we welcome contributions.. please add a comment if you want help and do the request against the 1.5.0 branch.

lukeapage avatar Jul 25 '13 17:07 lukeapage

I just now noticed that you' offered to do a PR. That would be great, what lib(s) are you thinking of using? How would you do this to account for node.js vs browser etc.?

jonschlinkert avatar Jul 25 '13 18:07 jonschlinkert

I'm not sure how I would implement the feature in the browser. Do you have any thoughts @jonschlinkert?

luk3thomas avatar Jul 25 '13 18:07 luk3thomas

No thoughts on it lol, I was hoping you did. The general consensus has been that only node.js should be supported, but who knows I thought maybe you had some ideas for how it would work in the browser and I didn't want to discourage it prematurely.

What about dependencies? Minimatch?

@cowboy, I noticed you created https://github.com/gruntjs/grunt-glob and https://github.com/gruntjs/grunt-file, any chance those are happening in the short-term(er), or are those still in the "maybe" stage? IMO having those available as utility libs could be useful for this kind of feature.

jonschlinkert avatar Jul 25 '13 18:07 jonschlinkert

@jonschlinkert grunt-glob will eventually be the new name of globule, which you can use right now. grunt-file is going to take a little longer, because I need to figure out how I'm going to handle logging first.

cowboy avatar Jul 25 '13 18:07 cowboy

@cowboy, thanks

so @luk3thomas I'll just wait and see what you come up with and we can go from there. thanks!

jonschlinkert avatar Jul 25 '13 19:07 jonschlinkert

Ok thanks, @jonschlinkert. I'll take a look and post some thoughts later

luk3thomas avatar Jul 25 '13 20:07 luk3thomas

:+1:

jonschlinkert avatar Jul 25 '13 20:07 jonschlinkert

I have an idea how to support a number of "node" features like this one with some rewriting to browser mode.

matthew-dean avatar Jul 25 '13 23:07 matthew-dean

I have an idea how to support a number of "node" features

start thinking out loud on here then lol. let's get these ideas flowing so people can build on them!

jonschlinkert avatar Jul 26 '13 00:07 jonschlinkert

there should be a well defined interface to the environment.. 1.5.0-wip is closer to that though not there yet. We should add a function on the environment importer that asks the importer if the url might be for multiple imports, then another function with callback that returns those imports. Then we add a little bit of extra code to the import visitor that calls these functions in order to get a list of imports and expands the one import into multiple before continuing with the standard import process.

lukeapage avatar Jul 26 '13 07:07 lukeapage