Skip to content

Nested SCSS selectors breaking @apply directive #9742

@shengslogar

Description

@shengslogar

What version of Tailwind CSS are you using?

v3.2.1

What build tool (or framework if it abstracts the build tool) are you using?

Laravel Mix v6.0.49

What version of Node.js are you using?

v16.18.0

What browser are you using?

N/A

What operating system are you using?

macOS Ventura

Reproduction URL

https://github.com/shengslogar/tailwind-scss-nesting-bug-report/blob/main/output.css#L469-L493

Describe your issue

Complex nested SCSS selectors seem to be breaking the @apply directive.

Input:

.foo {
  &:not(.bar) {
    @apply bg-red-100;
    background: red;

    &.baz > .bam {
      @apply bg-orange-100;
      background: orange;
    }
  }
}

Output:

.foo:not(.bar) {
  --tw-bg-opacity: 1;
  background-color: rgb(254 226 226 / var(--tw-bg-opacity));
  background: red;
}

.foo.baz.bam:not(.bar) >  {
  --tw-bg-opacity: 1;
  background-color: rgb(255 237 213 / var(--tw-bg-opacity));
}

.foo:not(.bar).baz > .bam {
  background: orange;
}

Expected Output:

.foo:not(.bar) {
  --tw-bg-opacity: 1;
  background-color: rgb(254 226 226 / var(--tw-bg-opacity));
  background: red;
}

.foo:not(.bar).baz > .bam {
  --tw-bg-opacity: 1;
  background-color: rgb(255 237 213 / var(--tw-bg-opacity));
  background: orange;
}

Thanks in advance! 🙏

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