Score:-3

External CSS file isn't loaded

dz flag

I am trying to load an external CSS file to globally effect my website.

I have tried the following in /core/themes/olivero/olivero.libraries.yml but no change occured after cache rebuild.

global-styling:
  version: VERSION
  css:
    base:
      css/base/fonts.css: {}
      css/base/base.css: {}
      css/base/utility.css: {}
      css/base/https://raw.githubusercontent.com/USER/REPOSITORY/main/website/style.css: { type: external, minified: false}

Removing css/base/ from before the URL doesn't matter.

Why does the external CSS file isn't loaded?

berliner avatar
bd flag
Welcome to Drupal Answers! There is documentation about this on drupal.org: https://www.drupal.org/docs/develop/theming-drupal/adding-assets-css-js-to-a-drupal-theme-via-librariesyml#external
berliner avatar
bd flag
Looks like a duplicate of https://drupal.stackexchange.com/questions/188377/how-can-i-add-an-external-cdn-css-style-sheet-to-a-theme
themer avatar
dz flag
I doubt it's a dupe because I don't use any CDN.
apaderno avatar
us flag
Using a CDN does not make any difference. Drupal does not handle CDN URLs differently from other external URLs.
Score:0
de flag

This:

global-styling:
  version: VERSION
  css:
    base:
      css/base/fonts.css: {}
      css/base/base.css: {}
      css/base/utility.css: {}
      css/base/https://raw.githubusercontent.com/USER/REPOSITORY/main/website/style.css: { type: external, minified: false}

Should be this:

global-styling:
  version: VERSION
  css:
    base:
      css/base/fonts.css: {}
      css/base/base.css: {}
      css/base/utility.css: {}
      //raw.githubusercontent.com/USER/REPOSITORY/main/website/style.css: { type: external, minified: false}

Make sure you clear the registry when you're done. If it doesn't load, look at the HTML source, and show us what is being loaded.

themer avatar
dz flag
From `Developer tools >> Network >> CSS`, this file, alongside other CSS files from Drupal itself, is now being loaded (thereofre I gladly accepted the answer). But for some reason the CSS in that particular file, which is `* {display: none !important;}` doesn't effect the website at all (after cache rebuild from Drush), i.e. it doesn't override all Drupal-original CSS files, those from core, and those from Asset Injector module.
Jaypan avatar
de flag
Sounds like a different problem.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.