Use case:
There is a sub-theme of bootstrap and the site build decides to develop a sub-theme of that sub-theme, simply to override some of the css. In such a case the override.min.css gets included after the theme css of the sub-theme and before the css of the sub-sub-theme.
However, it should be included before the css of the sub-theme.
The code:
In Drupal\bootstrap\Plugin\Alter\LibraryInfo::alter() which is triggered by the current theme (a.k.a. sub-sub-theme) the override.min.css gets added to
$libraries['theme']['css']['theme']
but it should be added to
$libraries['theme']['css']['base']
I'll post a patch in a minute.
Comments
Comment #2
jurgenhaasComment #3
markhalliwellYour sub-theme can alter the libraries if necessary, but I would say that your base/sub/sub-sub theme architecture needs some work so it only loads the overrides only once (unless I'm missing something here?), i.e.:
Base theme: Use CDN (loads overrides.min.css)
Sub-theme: Don't use CDN (doesn't load overrides.min.css as it's inherited from base theme)
Sub-sub-theme: Don't use CDN
Core should properly handle the weights based on the order of the library declarations in the theme ancestry.
Comment #4
markhalliwellSorry, wrong status.
Comment #5
jurgenhaasWell, here is what the current code base is producing:
Example 1 with sub-theme bootstrap_clean_blog, CDN enabled:
This is the order of libraries/theme/base followed by libraries/theme/theme
The sub-theme has a chance to override certain thing from the base theme, including stuff in override.css
Example 2 with sub-theme bootstrap_clean_blog and sub-sub-theme bootstrap_fanom, CDN enabled:
This is where the order gets confusing. The current theme (bootstrap_fanom) is looking for stuff in the base them and this is where override.css gets added to libraries/theme/theme. However, as bootstrap_clean_blog has added its own stuff to libraries/theme/theme already before, override.css suddenly gets output behind that. And now the overrides in bootstrap_clean_blog no longer apply.
From my point of view, overide.css belongs to libraries/theme/base always, no matter how many levels of sub-themes we're going to see. And I can not think of any downside when applying that change, it would work if bootstrap were on its own as well as in both samples given above.
Comment #7
markhalliwellThanks for the detailed information. That certainly helps clarify what you were talking about.
I went ahead and committed your patch with a few minor changes to help fix the documentation/comments around the code. I still credited you though since you came up with the patch. Thanks @jurgenhaas!
Comment #8
jurgenhaasThanks a lot @markcarver