Managing Frontend Libraries in Drupal 8

davidhernandez

Drupal 8 revolutionizes the theming experience with many significant improvements to make theming easier, and give themers the flexibility and control they've never had before. One of those major improvements is to the library management system, which controls the attaching of CSS and JavaScript files.

In this session we will cover how to create and control libraries from a theme. This will include SMACSS categorization for CSS files, dependencies, how to conditionally attach libraries, manipulating libraries that come from anywhere in a site (core, modules, or base themes,) and targeting individual files for removal or replacement. All this without needing a single line of PHP.


Experience Level

While the topics covered are not difficult, it would be helpful for attendees to have some prior experience theming in Drupal. We will discuss some of the challenges faced managing CSS and JavaScript in previous version of Drupal, and how Drupal 8 aims to solve them. The majority of the code displayed is in YAML format, or from Twig. It is not difficult to understand for a beginner, but some prior knowledge will help.


Take Aways

After this session, attendees should feel comfortable managing assets (CSS and JavaScript files) in Drupal 8 for the majority of use cases.

Session Track

Front End

Experience Level

Intermediate

Drupal Version