2

I just built a custom theme for Drupal 10. When enabling it via /admin/appearance, the dreaded message “The website encountered an unexpected error. Try again later.“ appears. drush watchdog:show says:

Error: Undefined constant "CSS_STYLE" in constant() 
(line 184 of web/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php)

My theme’s machine name is neinundamen. This is the neinundamen.info.yml file:

name: neinundamen
type: theme
'base theme': drupal_theme_letztegeneration
description: Subtheme of drupal_theme_letztegeneration
package: Custom
core_version_requirement: ^10
libraries:
  - neinundamen/global
regions:
  - ...

Here is the neinundamen.libraries.yml file, where I suspect my mistake - but I cannot see a problem.

global:
  css:
    style:
      css/style.css: {}

I tried the usual Drupal steps: updating to the most recent core version, clearing the cache using drush cr, drinking coffee.

3
  • Can you remove the quotes from 'base theme' please, flush cache and try again?
    – leymannx
    Commented Apr 7 at 9:53
  • Try to tackle it down systematically. Like remove everything from your info file keep only the minimum, retry, add stuff back until the error pops up again, then you know where it is. Or: use Drush to generate a new theme and then add stuff until the error pops up again.
    – leymannx
    Commented Apr 7 at 9:55
  • Thanks, @leymann. Removing the quotes didn’t help, but you’re right: drush generate theme won’t have quotes there. Commented Apr 7 at 10:09

1 Answer 1

3

You used the key style, but that is not part of the 5 allowed keys. Replace style: with theme: and you should be fine.

From the documentation:

You can set CSS weights with 5 different levels of styling:

  1. base: CSS reset/normalize plus HTML element styling. Key assigns a weight of CSS_BASE = -200
  2. layout: macro arrangement of a web page, including any grid systems. Key assigns a weight of CSS_LAYOUT = -100
  3. component: discrete, reusable UI elements. Key assigns a weight of CSS_COMPONENT = 0
  4. state: styles that deal with client-side changes to components. Key assigns a weight of CSS_STATE = 100
  5. theme: purely visual styling (“look-and-feel”) for a component. Key assigns a weight of CSS_THEME = 200

These 5 levels are defined by the SMACSS standard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.