Skip to content
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

Improve missing layer codemod #14512

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Improve missing layer codemod #14512

merged 2 commits into from
Sep 25, 2024

Conversation

RobinMalfait
Copy link
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
3 checks passed
@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