-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add name/index.less to file search path #2879
Comments
How many Less libraries do you know with their master file named |
@seven-phases-max I believe it could be just a question of defaults. Analysing its correlation with CommonJS makes it easier to understand: var foo = require('./foo');
var foo = require('./foo/index');
var foo = require('./foo/index.js'); All the examples above are valid ones, so nothing prevents users to have their main file pointing to something different like So I believe the suggestion might not only serve a purpose to save 5 characters but instead seeing things in a more modular fashion, the stylistic beauty comes as a bonus. Also, the similarity between javascript modules and less files would certainly be a very pleasing way to work with. Considering the following file structure:
Look at how similar javascript and less files get in terms of structure. main.less @import './lib/nav';
@import './lib/video';
@import './lib/auth';
… main.js var nav = require('./lib/nav'),
video = require('./lib/video'),
auth = require('./lib/auth');
… Of course in both cases the Honestly, I would believe that if this same decision was taken in order to adapt this kind of behaviour into other systems, it could mean a positive thing. |
@seven-phases-max Also in regards to your question:
Replying with another question might be an interesting way to analyse the current situation. How many Less libraries have you currently required in the following manner: So I believe in this case there's a rather unnecessary redundancy in regards directory name and file name. I have seen quite a few libraries doing that. Actually, based on my experience, the great majority. But that's just because currently there's no other intuitive way to do it. |
This implies the addiction to a particular naming/code-structuring scheme... I know it's pretty much useless to resist to a popular and wide-spread (in a certain realm) pattern, but for those who came from other realms all this may not be so natural. Either way, the answer is probably in "Implement as plugin" (Less itself is not supposed to be a package/module manager like |
That makes sense — Separating it as a plugin. Thanks for your help @seven-phases-max. |
To answer:
None. I use another code structuring pattern where the component master file is not put into the directory of auxiliary/asset files of that component, so in my realm all these imports look just like: @import "lib/button"; // ->"lib/button.less" which then refers to whatever files in `lib/button` (or whatever) dir
@import "lib/nav";
@import "lib/etc"; |
But that makes it impossible to integrate with package managers (bower, npm, etc) where they are downloaded inside their own directories. So for the everyone using those, would certainly be left out. It certainly works within your system but if you just look around you will see many of the examples mentioned. Lesshat as possibly being one of the most downloaded Less libraries out there. Installation:
Importing: @import 'node_modules/lesshat/build/lesshat.less';
@import 'bower_components/lesshat/build/lesshat.less'; In this case they have the build directory as well, but the issue with repeating module-names are still in place. Also, in regards your mention:
CommonJS can certainly be categorised in the same level as Less since it just interprets modules but is not responsible for managing them. So in that case the You have mentioned the plugin solution which I would be happy to attempt, but I am not sure if a plugin would have any chance to interact and act on how and where Less reads/searches files from? Would you by any chance have any recommendations? |
Just a confirmation I am not alone on this: sass/sass#690 |
This is a duplicate issue/request. Will find/tag the duplicate when I have a moment, unless someone else can. |
Closing as duplicate of #1339. |
I believe it would be very beneficial for Less users who want to split their work in modules on different directories to allow Less to search for files named
index.less
within that directory in case the format can't be found, this would help requiring dependencies in the same fashion other systems allow, like commonJS?For example, the below would be valid:
Perhaps there's already an way to achieve this behaviour? If someone could let me know it would be really appreciated.
Thanks in advance.
The text was updated successfully, but these errors were encountered: