Andrew Fletcher published: 20 July 2023 1 minute read
I've been working on a problem where a font and image tag aren't appearing on the front end of my website. I found that if I disable CSS aggregation, the YouTube play button symbol and overlay will appear. However, this slows down the page speed.
How to leverage CSS aggregation but set specific files to be excluded?
I'm wondering how to leverage CSS aggregation but exclude specific files. Here's an example of what my theme libraries file looks like:
global-styling:
version: 1.x
header: true
css:
base:
assets/dist/css/tailwind.css: {}
assets/dist/css/style.css: {}
assets/dist/css/responsive.css: {}
theme:
assets/dist/css/editor.css: {}
assets/dist/css/layout.css: {}
assets/dist/css/navigation.css: {}
assets/dist/css/headers.css: {}
assets/dist/css/button-link.css: {}
assets/dist/css/misc.css: {}
assets/dist/css/homepage.css: {}
assets/dist/css/forms.css: {}
assets/dist/css/vendors.css: {}
dependencies:
- core/jquery
- core/drupal
- core/jquery.once
- core/drupal.ajax
- core/views.ajax
To exclude a CSS file, you need to add { preprocess: false } against the relevant file. To exclude misc.css file it will look as follows:
global-styling:
version: 1.x
header: true
css:
base:
assets/dist/css/tailwind.css: {}
assets/dist/css/style.css: {}
assets/dist/css/responsive.css: {}
theme:
assets/dist/css/editor.css: {}
assets/dist/css/layout.css: {}
assets/dist/css/navigation.css: {}
assets/dist/css/headers.css: {}
assets/dist/css/button-link.css: {}
assets/dist/css/misc.css: { preprocess: false }
assets/dist/css/homepage.css: {}
assets/dist/css/forms.css: {}
assets/dist/css/vendors.css: {}
dependencies:
- core/jquery
- core/drupal
- core/jquery.once
- core/drupal.ajax
- core/views.ajax
Related articles
Andrew Fletcher
•
09 May 2024
Accessing nested paragraph fields in Drupal: a step-by-step reference
The issue – I have a content type that includes an entity reference revisions field named field_introduction. This field points to a paragraph, which itself contains a text field also named field_introduction, of the type Text (formatted, long). How can I access the content stored in this...
Andrew Fletcher
•
09 May 2024
How to retrieve the current menu title in Drupal – a developer’s reference
When building a theme in Drupal, it's often necessary to adapt your site’s UI dynamically based on the context in which a user is navigating. One such piece of dynamic content is the menu title. Achieving this can be a bit tricky due to the layered nature of its routing and menu systems. This...
Andrew Fletcher
•
07 May 2024
Understanding and resolving a Drupal render array error
Dealing with errors in Drupal development is a common occurrence, and understanding how to interpret and resolve them is essential for smooth development workflows. In this article, we'll delve into a specific error message related to render arrays in Drupal and discuss steps to diagnose and fix the...