Skip to content

Add support for import at-rule layer functionality #4340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 30, 2025

Conversation

puckowski
Copy link
Contributor

What:

Add support for @import layer functionality documented in https://developer.mozilla.org/en-US/docs/Web/CSS/@import

Builds on top of #4337

@import url("theme.css") layer(theme);
@import url("features.css") layer(features) supports(display: grid);
@import url("responsive.css") layer(responsive) supports(display: flex) screen and (max-width: 768px);
@import url("print.css") layer(print) print;

The above syntax has widely available browser support according to MDN.

Why:

Supporting the additional @import CSS syntax may benefit Less users.

Checklist:

  • Documentation
  • Added/updated unit tests
  • Code complete

I did not venture into .less imports using this syntax as existing import code makes a clear distinction between .css and .less and the two have significantly different behavior.

* Add support for layer at-rule.
* Add tests for layer at-rule.
* Cleanup layer import at-rule solution before merge.
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 16, 2025
@luangong
Copy link

Hi @puckowski! Do you have updates on this? Thanks!

@puckowski
Copy link
Contributor Author

@luangong Hello, this PR is currently awaiting peer review from another Less.js contributor before it can be merged.

@matthew-dean What do you think of this PR to enhance @layer capabilities?

@matthew-dean
Copy link
Member

@puckowski Sorry for missing this. So this just adds support for layer() in the @import statement?

@puckowski
Copy link
Contributor Author

Yes, this PR bolsters @import parsing capabilities with support for:

@import url layer(layer-name);
@import url layer(layer-name) supports(supports-condition);
@import url layer(layer-name) supports(supports-condition) list-of-media-queries;
@import url layer(layer-name) list-of-media-queries;

which are documented here: https://developer.mozilla.org/en-US/docs/Web/CSS/@import

@matthew-dean

* Add fix for media query list parsing in import.
* Add test for import with media query list syntax.
@matthew-dean
Copy link
Member

Cool, thanks!

@matthew-dean matthew-dean merged commit 67404cd into less:master May 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants