Skip to content

Improve missing layer codemod#14512

Merged
RobinMalfait merged 2 commits into
nextfrom
fix/keep-last-unlayered
Sep 25, 2024
Merged

Improve missing layer codemod#14512
RobinMalfait merged 2 commits into
nextfrom
fix/keep-last-unlayered

Conversation

@RobinMalfait

Copy link
Copy Markdown
Member

This PR improves the missing layers codemod where everything after the last Tailwind directive can stay as-is without wrapping it in a @layer directive.

The @layer at-rules are only important for CSS that exists between Tailwind directives.

E.g.:

@tailwind base;

html {}

@tailwind components;

.btn {}

@tailwind utilities;

.foo {}

.bar {}

Was transformed into:

@import "tailwindcss";

@layer base {
  html {}
}

@layer components {
  .btn {}
}

@layer utilities {
  .foo {}
  
  .bar {}
}

But the last @layer utilities is already in the correct spot, so we can simplify this to just this instead:

@import "tailwindcss";

@layer base {
  html {}
}

@layer components {
  .btn {}
}

.foo {}

.bar {}

@RobinMalfait RobinMalfait enabled auto-merge (squash) September 25, 2024 08:39
@RobinMalfait RobinMalfait merged commit 951f644 into next Sep 25, 2024
@RobinMalfait RobinMalfait deleted the fix/keep-last-unlayered branch September 25, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants