1

I'm trying to figure out how I can remove the default css libraries of Drupal 8 on the theme I'm working on. I tried using libraries-override: to remove a specific CSS but it doesn't seem to be working. The css file is still showing. As you can see the align.module.css is still showing on Google Network Tab. I'm not sure if the method I'm using is deprecated or incorrect

enter image description here

name: Barebones
description: Drupal light
type: theme
core: 8.x

base theme: stable

libraries-override:
  system/base:
    css:
      component:
        /core/modules/system/css/components/align.module.css: false

enter image description here

libraries-override:
  system/base: false

enter image description here

1 Answer 1

2

You can override a library using the filename as key.

libraries-override:
  system/base:
    css:
      component:
        css/components/align.module.css: false

But if your asset was already overwritten by another module (e.g. classy theme overriding a core system asset), you have to use the full path instead, example:

libraries-override:
  system/base:
    css:
      component:
        /core/themes/stable/css/system/components/ajax-progress.module.css: false

Also see this issue.

11
  • 1
    Did you clear the cache? e.g. drush cr
    – Hudri
    Nov 22, 2017 at 8:27
  • 1
    Sorry, was wrong with the path comment, found this issue: when your library is already overwritten, the key gets replaced with a drupal-root relative path, so your intial syntax should be correct. Enter the full path, starting with the drupal root.
    – Hudri
    Nov 22, 2017 at 8:47
  • 1
    The code in your initial question disables a single file of a library, the code in your last comment disables the entire library (all js and css files). Every active module in Drupal can define and add libraries, so you'll end up with a lot of CSS files (but they are usually needed for the functionality of that module, so don't disable them en gros)
    – Hudri
    Nov 22, 2017 at 9:10
  • 2
    Simple answer: no. If you want a lighter Drupal, disable some modules. By concept Drupal's frontend and backend are not fully separated, what you are trying to do will not work.
    – Hudri
    Nov 22, 2017 at 9:35
  • 1
    Glen, I've updated the answer, using both examples. Just removing that comment wouldn't help people wondering when to use the relative path and when the absolute path.
    – Hudri
    Jun 9, 2020 at 7:30

Your Answer

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