adapt_framework icon indicating copy to clipboard operation
adapt_framework copied to clipboard

LESS compilation order

Open oliverfoster opened this issue 8 years ago • 5 comments

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

  1. The LESS files are sorted by plugin type.
  2. Nested folders appear in alphanumeric sequence on the same standing as files: src\theme\adapt-contrib-vanilla\less\src\component.less src\theme\adapt-contrib-vanilla\less\src\custom\** src\theme\adapt-contrib-vanilla\less\src\drawer.less
  3. Some punctuation is sorted before word characters: src\extensions\adapt-contrib-trickle\less\trickle-button.less src\extensions\adapt-contrib-trickle\less\trickle.less

Expected behaviour

  1. The LESS files should be sorted by type. (no change)
  2. Nested folders should compile after files, such that: src\theme\adapt-contrib-vanilla\less\src\* src\theme\adapt-contrib-vanilla\less\src\custom\**
  3. Longer filenames should always compile after shorter ones, only where the front matches src\extensions\adapt-contrib-trickle\less\trickle.less src\extensions\adapt-contrib-trickle\less\trickle-button.less

Reasons

  1. This seems to be the expected behaviour from a few people around the theming stuff
  2. It allows for orderly overrides by making the LESS folder structure behaviour like CSS, where nesting and sub classes take precedence. buttons.less and buttons-overrides.less or buttons.less and buttons/overrides.less

oliverfoster avatar Feb 16 '18 11:02 oliverfoster

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.

lc-thomasberger avatar Feb 19 '18 14:02 lc-thomasberger

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.

oliverfoster avatar Feb 19 '18 14:02 oliverfoster

+1 for switching to webpack

lc-thomasberger avatar Feb 19 '18 16:02 lc-thomasberger

Hi @oliverfoster, have tested this and think all is fine. Nothing visible has broken so think should work nicely 👍

Nice job!

+1

nilslp avatar Feb 19 '18 16:02 nilslp

ta @nilslp

oliverfoster avatar Feb 19 '18 16:02 oliverfoster