Sometimes you want to alter the assets of a library by adding in your own additional library assets whenever a library is attached.
The most common use case in core is the Classy base theme, see.
Other use cases include:
- BigPipe (in core or contrib), where it is crucial because it means a theme's CSS extending other CSS is loaded not as part of the initial theme CSS, but as part of the CSS for the actual component. Remember that the component may be rendered *after* the initial page! So this ensures that we don't end up with 1. theme CSS, 2. component CSS, with 2 overriding 1, which is a problem in HEAD. With support for this, we completely avoid that problem.
- The last point also quite clearly shows how this makes Drupal 8 ready for a Web Component world.
libraries-override meet this specific use case.
There is also a big front-end performance win: rather than loading all the CSS extending existing CSS all the time, this ensures it's only loaded when necessary.
Allow code like the following in a theme's (and potentially module's?) *.info.yml file so that libraries can extend other libraries:
# Extend drupal.user: add assets from classy's user libraries. libraries-extend: core/drupal.user: - classy/user1 - classy/user2
Patch Patch review
User interface changes
Beta phase evaluation
|Issue category||Task because it is an API addition. Nothing is broken.|
|Prioritized changes||The main goal of this issue is TX, but there's also a strong front-end performance aspect, and an even stronger "unblock BigPipe" aspect.|
|Disruption||Unblocks much of the work in, otherwise not disruptive.|