0

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

Try removing the leading slash and the module path in the following line.

css/components/align.module.css: false

I think the filename is also used as a key; so, even if it is resulting in the same file path, it is not the same entry.

If your library was already overwritten by some other module/theme, you indeed have to use the full path to the CSS file, starting at the Drupal root. See this issue.

  • Tried your solution but it didn't work. Saw a similar question with a correct answer. drupal.stackexchange.com/questions/246796/… Tried doing the same solution but didn't work – user77193 Nov 22 '17 at 8:12
  • 1
    Did you clear the cache? e.g. drush cr – Hudri Nov 22 '17 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 '17 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 '17 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 '17 at 9:35

Your Answer

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