Libraries that have been defined in *.libraries.yml
can now be overridden or extended using the libraries-override and libraries-extend entries in a theme's *.info.yml
file.
Libraries-override
libraries-override
was added as a way for themes to manipulate assets (CSS/JS) provided by libraries. This includes removing or replacing assets, as well as removing a library altogether.
libraries-override:
# Replace an entire library.
core/drupal.collapse: mytheme/collapse
# Replace an asset with another.
subtheme/library:
css:
theme:
css/layout.css: css/my-layout.css
# Remove an asset.
drupal/dialog:
css:
theme:
dialog.theme.css: false
# Remove an entire library.
core/modernizr: false
Libraries-extend
libraries-extend
provides a way for themes to alter the assets of a library by adding in additional theme-dependent library assets whenever a library is attached.
Libraries-extend are specified by extending a library with any number of other libraries
# Extend drupal.user: from core.libraries.yml and add assets to
# classy's(classy.libraries.yml) user1 & user2 libraries .
libraries-extend:
core/drupal.user:
- classy/user1
- classy/user2
Sub-themes inherit the libraries-override
and libraries-extend
specified in base themes.
Examples of libraries-override
and libraries-extend
can be found in Bartik and Seven themes.