LESS compilation order
Subject of the issue
The LESS should currently be compiling by component type in alphanumeric ascending order. At the moment it can be variable as to how grunt fetches the LESS files to render. The only order that can be relied upon is component type ordering.
Relevant lines: core less plugin less
However... I don't think by component type then alphanumeric ascending is really what we want...
Current behaviour
- The LESS files are sorted by plugin type.
- Nested folders appear in alphanumeric sequence on the same standing as files:
src\theme\adapt-contrib-vanilla\less\src\component.lesssrc\theme\adapt-contrib-vanilla\less\src\custom\**src\theme\adapt-contrib-vanilla\less\src\drawer.less - Some punctuation is sorted before word characters:
src\extensions\adapt-contrib-trickle\less\trickle-button.lesssrc\extensions\adapt-contrib-trickle\less\trickle.less
Expected behaviour
- The LESS files should be sorted by type. (no change)
- Nested folders should compile after files, such that:
src\theme\adapt-contrib-vanilla\less\src\*src\theme\adapt-contrib-vanilla\less\src\custom\** - Longer filenames should always compile after shorter ones, only where the front matches
src\extensions\adapt-contrib-trickle\less\trickle.lesssrc\extensions\adapt-contrib-trickle\less\trickle-button.less
Reasons
- This seems to be the expected behaviour from a few people around the theming stuff
- It allows for orderly overrides by making the LESS folder structure behaviour like CSS, where nesting and sub classes take precedence.
buttons.lessandbuttons-overrides.lessorbuttons.lessandbuttons/overrides.less
Right now the theme always overwrites the plugins less. This should be the same as it would break all existing themes.
To me this is not to much of an issue. I usually have one file per component. Maybe a helper file that stores mixins that are used in another file. When I would split code into different files, I usually make sure that the order of the execution does not break things.
In the long run I think themes should define there own dependencies. For instance button-base.less. You may then overwrite those in the module that requires them. This will lead to smaller more composable themes and stylesheets.
It still sorts by plugin type: core, component, extension, menu, theme.
This won't affect highly atomic styles like the ones you're explaining.
I agree with you on the dependencies issue. If we move to webpack that will definitely need to happen and will make this issue redundant.
+1 for switching to webpack
Hi @oliverfoster, have tested this and think all is fine. Nothing visible has broken so think should work nicely 👍
Nice job!
+1
ta @nilslp