less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.02k stars 3.41k forks source link

Auto importing index file when @import a directory #3512

Closed Buzut closed 4 years ago

Buzut commented 4 years ago

In a similar fashion to many web standards, could we have the ability to reference a directory and have its index.less imported if it has one?

That would allow for a very streamlined workflow. Exemple:

header/
    index.less
    logo.less // logo with loads of style because it's animated
    navigation.less
    mobile-navigation.less

Now with this file hierarchy, one could @import header from the main stylesheet and be done with it. All other imports are to be managed by index.less. Loads of PHP and Node.js projetcs are structured this way, it would allow for a similar logic in terms of styling.

Currently, one would have to have a header.less outside of the header/ directory required as an intermediary file but it adds visual clutter to the main style directory.

Alternatively, one could use index.less in a header/ directory, but has then to import it explicitely with an ugly @import header/index.

matthew-dean commented 4 years ago

@Buzut This request has been made before. However, there are no current plans to add this feature, mostly because of the historical support of in-browser compiling, and the extra overhead of trying to request additional paths.

This may change in the future (4.0+)

Buzut commented 4 years ago

Understood, thanks for getting back to me and for clarifying the situation. Hope it's going to make it to 4.0+ then!