diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index 9798bc9..b07937a 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -132,13 +132,16 @@ public function buildByExtension($extension) { // and only once prior to rendering out an HTML page. if ($type == 'css' && !empty($library[$type])) { foreach ($library[$type] as $category => $files) { - // Allow empty categories. - if (defined('CSS_' . strtoupper($category)) && empty($files)) { - unset($library[$type][$category]); - continue; - } if (empty($files)) { - throw new InvalidCssDefinitionException(sprintf("Every CSS asset must be nested under a SMACSS category in the %s.library.yml file ('%s' seems to be a file name, allowed categories are Base, Layout, Component, State, Theme)", $extension, $category)); + // Allow empty categories. + if (defined('CSS_' . strtoupper($category))) { + unset($library[$type][$category]); + continue; + } + // Files are are in $category and $files is empty. + else if (empty($files)) { + throw new InvalidCssDefinitionException(sprintf("Every CSS asset must be nested under a SMACSS category in the %s.library.yml file ('%s' seems to be a file name, allowed categories are Base, Layout, Component, State, Theme)", $extension, $category)); + } } foreach ($files as $source => $options) { if (!isset($options['weight'])) {