2

I am trying to remove Drupal CSS files (such as ajax-progress.module.css) from my custom theme YML. Here is what I tried:

name: Mercante
type: theme
description: Tema para o site Mercante.co
core: 8.x
stylesheets-remove:
  - core/themes/stable/css/system/components/ajax-progress.module.css
libraries-override:
  system/base:
    css:
      theme:
        css/components/ajax-progress.module.css: false

Drupal's documentation about that is scarce at best...

Update: another version that also does not work:

name: Mercante
type: theme
description: Tema para o site Mercante.co
core: 8.x
stylesheets-remove:
  - @stable/css/system/components/ajax-progress.module.css
libraries-override:
  system/base:
    css:
      component:
        /core/themes/stable/css/system/components/ajax-progress.module.css: false
        /core/themes/stable/css/system/components/autocomplete-loading.module.css: false
1
2

You can try with the unset method that drupal provides for css alter hook. Try the following code in your custom module

function hook_css_alter(&$css) { 
unset($css[drupal_get_path('module','system').'/system.theme.css']);}
1
  • But I guess the "correct" way to remove a CSS is through libraries-override isn't it? Even stylesheets-remove didn't work.
    – rbaprado
    Feb 17 '16 at 14:50
1

You are correct. This is what I have and it is working:

libraries-override:
  core/normalize:
    css:
      base:
        assets/vendor/normalize-css/normalize.css: false
2
  • Do you think there is any difference since I am removing something from system/base?
    – rbaprado
    Feb 17 '16 at 14:56
  • I think you have wrong paths. You have to use the paths defined in the library and not absolute paths.
    – user21641
    Feb 17 '16 at 17:55
1

Quote from https://www.drupal.org/node/2473869

stylesheets-remove:
  - core/assets/vendor/jquery.ui/themes/base/dialog.css

In cases where a Drupal core asset is being removed (for example, a CSS file in jQuery UI) the full file path is needed. In cases where the file is part of a library that belongs to a module or theme, a token can be used. Note that when using the token it needs to be quoted because @ is a reserved indicator in YAML.

stylesheets-remove:
  - '@bartik/css/style.css'

As you are removing a stylesheet from the stable theme you should use the token @stable

1
  • I tried that, also not working.
    – rbaprado
    Feb 17 '16 at 15:30
1

The only way I managed to do it:

name: Mercante
type: theme
description: Tema para o site Mercante.co
core: 8.x
base theme: false
libraries-override:
  system/base:
    css:
      component:
        /core/modules/system/css/components/align.module.css: false

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.