Skip to content

Should not add comma separators for the @apply at-rule #4354

Closed

Description

@tmkx

To reproduce:

.box {
  @apply h-64 w-64;
}

Current behavior:

.box {
  @apply h-64, w-64;
}

Expected behavior:

.box {
  @apply h-64 w-64;
}

Environment information:

  • less version: 4.4.0
  • nodejs version: 22.17.1
  • operating system: macos

Activity

  1. dosubot commented on Jul 31, 2025

    @dosubot

    Hi @tmkx! I'm Dosu and I’m helping the less.js team.

    This is expected behavior in Less 4.4.0: unknown at-rules like @apply are parsed generically, and when you provide multiple values, Less joins them with commas in the output. There’s no built-in way to customize this for specific at-rules or to preserve space separation automatically [source].

    A practical workaround is to use string interpolation or escaping to force Less to treat the value as a single string, like this:

    .box {
      @apply ~"h-64 w-64";
    }

    or

    .box {
      @apply escape("h-64 w-64");
    }

    Both will output:

    .box {
      @apply h-64 w-64;
    }

    There’s no official documentation or plugin support for customizing at-rule argument formatting in Less as of 4.4.0 [source].

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about less.js with Dosu Add Dosu to your team

  2. tmkx commented on Jul 31, 2025

    @tmkx
    Author

    Escaping is not functioning properly with prettier-plugin-tailwindcss at the moment ([email protected], [email protected]).

    for the code below:

    .box {
      @apply ~'h-64 w-64 shadow-2xl';
    }

    it will be formatted to:

    .box {
      @apply ~'h-64 shadow-2xl' w-64;
    }
  3. liangskyli commented on Aug 11, 2025

    @liangskyli

    the same issues

  4. matthew-dean commented on Aug 18, 2025

    @matthew-dean
    Member

    @tmkx That said, I agree that adding commas is a bug.

  5. tmkx commented on Aug 19, 2025

    @tmkx
    Author

    yes, there are already some downstream issues: web-infra-dev/rsbuild#5688

  6. wldrve commented on Sep 1, 2025

    @wldrve

    Any fixes for this issue? I am trying to update less to the latest, but Vite can not process @apply rules, as all the @apply one-liners get processed with commas after each class.

  7. puckowski commented on Sep 1, 2025

    @puckowski
    Contributor

    I took a stab at it, not tying the logic to a specific at-rule: #4366

    @matthew-dean @iChenLei Would either of you be able to peer review?

  8. OverflowCat commented on Dec 25, 2025

    @OverflowCat

    This also breaks UnoCSS' transformer-directives: unocss/unocss#4908 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions