Drupal 8 - Remove Libraries via Theme

15.06.2016

Extending Drupal 8’s ‘Classy’ theme is a great way to bootstrap your theme. However, specifying a parent theme in your theme.info.yml will also include its libraries.

An easy way to remove included libraries from your child theme is to use libraries-override, like so:

# theme.info.yml
# ...
libraries-override:
  classy/base: false

This will stop the classy.base library from being included in your theme.

You can also override a library, changing which resources gets loaded:

# theme.info.yml
# ...
libraries-override:
  classy/base: my_theme/base
  classy/dialog:
    css:
      component:
        css/components/dialog.css: css/dialog.css

This will replace the classy.base library with my_theme.base library, and replace dialog.css from the classy/dialog library with your own dialog.css file.

Further Reading