Support for CSS Cascade Layer import in CssOptimizer

Created on 28 August 2024, 10 months ago

Problem/Motivation

CSS @import allows importing css into a cascade layer:
https://developer.mozilla.org/en-US/docs/Web/CSS/@import

The CssOptimizer merges imports into a single file, but currently ignores layers.

Steps to reproduce

Create a css file with enabled aggregation:

@import url('some.css') layer(some-layer);

The import will not be inlined.

Proposed resolution

Extend CssOptimizer to support layers

Remaining tasks

  1. add layer support too core/lib/Drupal/Core/Asset/CssOptimizer.php
  2. update test assets: css_input_with_import.css.optimized.css & css_input_with_import.css.optimized.aggregated.css

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
CSSΒ  β†’

Last updated 1 day ago

Created by

πŸ‡©πŸ‡ͺGermany woldtwerk Stralibu

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

Merge Requests

Comments & Activities

  • Issue created by @woldtwerk
  • Merge request !9361Issue #3470829: add @import layer support β†’ (Open) created by woldtwerk
  • Pipeline finished with Success
    10 months ago
    Total: 1548s
    #267528
  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • πŸ‡©πŸ‡ͺGermany woldtwerk Stralibu

    Do you have any hints on how to run specific Tests and update the fixture data?

  • πŸ‡©πŸ‡ͺGermany woldtwerk Stralibu

    Also why does the regex not allow stream wrappers? It's explicitly excluded with the negative lookahead

  • I noticed that the current regex excludes stream wrappers. Could you clarify the reasoning behind this exclusion? Are there specific edge cases or security concerns being considered here? It might be helpful to document these in the code comments for better clarity.

    Also, regarding the test casesβ€”are there any guidelines or examples for contributors who want to run specific tests and update the fixture data? Clear instructions could encourage more contributors to test and validate this feature.

  • πŸ‡©πŸ‡ͺGermany woldtwerk Stralibu

    The patch is from a private project. There I have streamwrappers like libraries:// which points to web/libraries

    I guess this patch should keep the negative lookahead

Production build 0.71.5 2024