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

[Feature request] - Import directory #580

Closed
alexwhitman opened this issue Jan 18, 2012 · 22 comments
Closed

[Feature request] - Import directory #580

alexwhitman opened this issue Jan 18, 2012 · 22 comments

Comments

@alexwhitman
Copy link

I've got a number of modules I'm writing styles for, one file per module, and currently I'm importing each .less file. Instead it would be useful to just able to @import 'directory_of_files/' which would include all of the less/css files in the directory.

@ivanovyordan
Copy link

How do you imaginate this? This is impossible. LESS is a cliend-side javascript solution. What you are looking should be a server-side solution.

@cloudhead
Copy link
Member

LESS is both client and server, depending on preference.. I could look into this if I have time.

@paulogaspar7
Copy link
Contributor

Ordering not important?

@alexwhitman
Copy link
Author

Ordering could be an issue but in my use case I've got a 'modules' directory which has styles for different modular components (each module has a .less file) where it doesn't matter what order they get included in.

@roblafeve
Copy link

@whitman, did you ever find the solution?

@alexwhitman
Copy link
Author

@roblafeve I didn't. In the end it wasn't really an issue to just add the individual files. It could still be a useful thing though.

@matthew-dean
Copy link
Member

I think this would break client-side functionality. The web page doesn't know what files exist on the server, hence it can't import a directory without a server-side script. Because of that, and since another solution was found, I recommend closing this issue.

@lukeapage
Copy link
Member

Seconded.

@hypesystem
Copy link

I still think this would be a great feature server-side. "This is hard" is hardly an excuse to close it.

@lukeapage lukeapage reopened this Jan 31, 2014
@lukeapage
Copy link
Member

reopened
as long as it fitted into our new environment system so it would essentially give the environment a path and ask for a list of files and the browser environment could throw an error - not supported then I think this would be useful, if low priority addition.

There is another issue thats similiar knocking around too.

@matthew-dean
Copy link
Member

@lukeapage Duplicate of #1181 and #1413 (or those are duplicates of this).

@matthew-dean
Copy link
Member

Also, yes, with a proper return value of either the directory list or "not supported", this would probably be okay at that point.

@davidcalhoun
Copy link

This would be extremely useful. It would also be a nice advantage over using SASS, which also doesn't have this feature.

@neemzy
Copy link

neemzy commented Feb 10, 2014

I've got to +1 this :) I can live without it but it would be a great improvement to me to have this feature. Well, that was my 2 cents !

@jonschlinkert
Copy link
Contributor

I now think this is something best implemented with a plugin. I'd rather see the API evolve so that the various approaches to file loading are kept out of Less.js core, which (IMHO) should really be focused on parsing.

if we were to add this to less.js core though, I think #1181 would be much more advantageous, since globbing patterns allow you to load directories of files, specific files, exclude files or extensions, and so on.

@matthew-dean
Copy link
Member

I now think this is something best implemented with a plugin.

@jonschlinkert I'm starting to lean that way too, especially as the API / plugin stuff is gaining momentum. I'm even thinking we should consider moving anything from core to plugins that isn't cross-platform (Node/Rhino/Browser), such as data-uri.

Which of course, means this issue is still valid, it just may be addressed in a different way, yes?

@jonschlinkert
Copy link
Contributor

moving anything from core to plugins that isn't cross-platform (Node/Rhino/Browser)

Lol, I was thinking the opposite. If you think about it (if @lukeapage, @seven-phases-max et al had unlimited time, desire, and incentive to do so) ideally the core would be focused on code that is platform agnostic, leaving platform implementations to other "contrib" projects, e.g less-cli, less-node, less-rhino, less-browser etc, and then plugins would handle application code and edge cases. As with many other plugin-oriented tools, it would be trivial enough to init new projects with your favorite less-contrib and less user-plugins.

I'm personally in favor of this route. I can envision a time when the issues on Less.js are almost entirely related to language features, parsing, and related performance and reliability. While other libs would be created to deal with file loading, environment differences, CLI, etc.

@jonschlinkert
Copy link
Contributor

wait, I just re-read lol. you said the same thing. I read it backwards the first time... I read "isn't cross-platform" as "is cross-platform".

anyway, good stuff!

@matthew-dean
Copy link
Member

^_^

I think we're all on the same page.

@lukeapage
Copy link
Member

Technically its easier to change less so that it asks its environment for a
list of files for an import and then its up to the environment -
node/browser/rhino etc to either do that, error or return what it was given.

Because of the way imports work this particular feature will be harder to
do as a plugin, but yes it can be environment specific.

@lukeapage lukeapage added this to the 2.0 milestone Feb 13, 2014
@steelbrain
Copy link

Bump!

@lukeapage
Copy link
Member

merging with #1181

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

No branches or pull requests