Disable CSS Aggregation for Specific CSS files in Drupal 8
Image source: Joshua Brandenburg

Disable CSS Aggregation for Specific CSS files in Drupal 8

November 27, 2015

How to Force Drupal to NOT aggregate specific CSS files.

Generally we want to aggregate all our CSS into one file. This is how Drupal libraries work by default. However, there are some use cases when you will need to NOT aggregate some specific CSS files, while aggregating all of the rest.

This will need to be done, for example, for any file that is intentionally breaking itself up into multiple, smaller files by using multiple imports to work around IE CSS selector limits. See http://blesscss.com/.

When creating a library in Drupal, set “preprocess” to false for that specific CSS file.

msk.globalstyles:
   css:
     theme:
       assets/styles/legacy.css: { browsers: { IE: 'lt IE 9', '!IE': false }, preprocess: FALSE }

For more information see my post all about including JS and CSS in your Drupal 8theme using libraries.