Skip to content

PostCSS: At-rule to exclude layers (@unocss !<layer-name>) #4697

@songpola

Description

@songpola

Clear and concise description of the problem

Layers cannot be individually excluded from @unocss at-rule.

Suggested solution

Currently, we can inject each layer individually using @unocss <layer-name> at-rule with the layer name, e.g.: @unocss preflights. This will replace the at-rule placeholder with only the generated preflights layer (and add the layer to the exclude list to not generate it again in the fallback @unocss at-rule).

I suggest being able to specify layers to be excluded in @unocss at-rule.
Maybe a syntax like: @unocss !<layer-name> ...

Example

This should generate all the rules, except the preflights layer:

@unocss !preflights;
@unocss;

Alternative

No response

Additional context

I'm trying to separate the properties layer from the rest of the styles into a file (ref: presetWind4).

File: properties.css

@unocss properties;

File: style.css

@unocss;

File: main.ts

...
import "./properties.css"
import "./style.css"
...

But the @unocss at-rule only operates at the file-level; So, it won't exclude the properties layer specified in another file.

With this proposal, I can adjust the style.css file to be like this, and it should work:

@unocss !properties;
@unocss;

Validations

  • Read the Contributing Guidelines.
  • Read the README.md of using the package.
  • Already used the Interactive Docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions