2

I'm trying to add Font Awesome to a Bootstrap subtheme I have made.

Here is the code I am using in subtheme.libraries.yml, which is based on the documentation for hosting external JS libraries in Drupal 8:

font-awesome:
  remote: https://fortawesome.github.io/Font-Awesome/
  version: 4.5.0
  license:
    name: MIT
    url: https://fortawesome.github.io/Font-Awesome/license/
    gpl-compatible: true
  css:
    https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css: { type: external, minified: true }

Unfortunately this results in a WSOD. The error log gives these two errors:

Warning: constant(): Couldn't find constant CSS_HTTPS://MAXCDN.BOOTSTRAPCDN.COM/FONT-AWESOME/4.5.0/CSS/FONT-AWESOME.MIN.CSS in Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension() (line 143 of /srv/bindings/code/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).

And:

Warning: Illegal string offset 'weight' in Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension() (line 143 of /srv/bindings/928c941920f8443d9e50a3d908967fee/code/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).

  • 1
    css requires additional key for base, theme or component. Also maybe use quotation marks. – user21641 Jan 28 '16 at 16:33
2

My understanding was that for a sub theme you defined the CSS as such:

global-styling:
  css:
    theme:
      css/style.css: {}

...as discussed here: https://www.drupal.org/node/2165673

  • Yes, 'theme' is missing and likely will resolve it. However, it does not seem that the docs page mentions external CSS, only external JS. – Kevin Jan 28 '16 at 17:03
  • I also needed to add subtheme/font-awesome to subtheme.libraries.yml. – Patrick Kenny Jan 29 '16 at 3:47
1

This worked for me, as of the 8.0.4 core release:

googlefonts-ptsans:
version: 1.0
license:
  name: google fonts
  url: https://www.google.com/fonts#AboutPlace:about
  gpl-compatible: true
css:
  base:
    https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700italic,700: {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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