custom-style.css not found

Created on 26 February 2025, about 1 month ago

Problem/Motivation

As solution for issues/3504795 you created a setting to define in what directory the custom css is present. A very usefull addition. Thanks.
After defining the settting and placing the css file in the custom directory (and clearing all caches), I get now this message:
Warning: file_get_contents(themes/contrib/zeropoint/themes/custom/zeropoint/custom-style.css): Failed to open stream: No such file or directory in Drupal\Core\Asset\CssCollectionOptimizerLazy->generateHash() (line 43 of /xxx/core/lib/Drupal/Core/Asset/AssetGroupSetHashTrait.php)
I cleared all caches again, but this message still appears. Why should it be placed as well in the original location?

🐛 Bug report
Status

Active

Version

1.25

Component

Code

Created by

🇳🇱Netherlands promes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @promes
  • 🇳🇱Netherlands promes

    The custom-style.css file is defined in admin/appearance/settings/zeropoint as: themes/custom/zeropoint/custom-style.css.
    when I look in de sourcefile of a site page I find this link:
    <link rel="stylesheet" media="all" href="/themes/contrib/zeropoint/themes/custom/zeropoint/custom-style.css?sslgqd" />.
    When I click on that link I get this text:
    <!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "https://www.heerdersoos.nl/themes/contrib/zeropoint/themes/custom/zeropoint/custom-style.css?sslgqd=" was not found on this server.</p></body></html>
    My conclusion: the link url of the custom css should be corrected.

  • 🇳🇱Netherlands promes

    Since the new ordering of css aggregation I changed in another site with a subtheme the subtheme-style.css definition in mysubtheme_theme.libraries.yml to have this css last in the list into:
    subtheme-global:
    version: VERSION
    css:
    theme:
    css/subtheme-style.css: {preprocess: false}
    The preprocess: false does the trick. I hope it helps in a solution.

    For the time being I removed function zeropoint_library_info_alter() in zeropoint.theme and changed in zeropoint.libraries.yml 'weight' => 210 into preprocess: false:
    zeropoint-custom:
    Version: VERSION
    css:
    theme:
    _custom/custom-style.css: {preprocess: false}
    And of course I use the old location of _custom/custom-style.css.

  • 🇲🇹Malta florian

    Please check your theme settings>

    The custom CSS file path should be something like _custom/custom-style.css if you want the file to be placed in the _custom folder.
    You may place the file outside theme folder: ../custom-style.css

  • 🇳🇱Netherlands promes

    In xxx/admin/appearance/settings/zeropoint I defined the location of the custom css file to be in: themes/custom/zeropoint/_custom/custom-style.css
    or:
    folder: themes/custom/zeropoint
    path: /_custom/custom-style.css

    You say:
    The custom CSS file path should be something like _custom/custom-style.css if you want the file to be placed in the _custom folder.
    You may place the file outside theme folder: ../custom-style.css

    What is the difference? Must it be:
    folder: themes/custom
    path: /custom-style.css

    With your setting (see attachment) I still get this message:
    Warning: file_get_contents(themes/contrib/zeropoint/themes/custom/custom-style.css): Failed to open stream

Production build 0.71.5 2024