Hello Drupal Community!

I'm (obviously) new to Drupal and have seen this question repeated a hundred times in the forums, but am unable to find clarity. It's likely I'm misunderstanding how to add CSS to an existing theme. This is on a local server so I'm seeking understanding rather than someone to fix this for me. From my understanding to add CSS/JS:

Add source to /themes/selected_theme/selected_theme.libraries.yml

global-components:
  css:
    theme:
      ...
      css/my-file.css: {}

Verify library is listed in themes/selected_theme/selected_theme.info.yml

libraries:
  ...
  - selected_theme/global-components

Verify CSS source in place themes/selected_theme/css/my-file.css

I thought this would be the end of it, but I'm obviously missing something. Thank you in advance.

Comments

Jeff Burnz’s picture

I take it you do not actually have ... in the file and that represents other files? If not, that's your issue.

Otherwise did you clear the cache and have you checked in a web inspector, e.g. Chrome Network tab for a loading issue?

JonathonCarlyon’s picture

Yes, ... Represents other CSS files and other libraries used by the theme. I made sure to put my CSS declaration below the themes's native stylesheets in libraries.yaml

Good call on web inspector I'll take a look next chance I get, thanks I didn't think of that.

I cleared browser cache, but since I'm still new to drupal I'm unaware of how it caches assets.

I'll triple check there are no typos in paths, but is the process I described all I should have to do for style sheets to take effect?

I've always heard drupal has a friendly community. Thanks for the help.

JonathonCarlyon’s picture

My issue was resolved by clearing the cache in Drupal located in Home > Administration > Configuration > Development.