tailwindcss/packages/@tailwindcss-upgrade/src
Jordan Pittman 2030e942bc
Don't consider the global important state in @apply (#18404)
Fixes #18400

In v3 when you used `important: true` it did not affect `@apply`.
However, in v4 it does and there's no way to make it *not*. This is
definitely a bug and would be unexpected for users coming from v3 who
use `@apply` and `important` together.

Basically, the following code, along with the detected utility `flex` in
source files…

```css
@import 'tailwindcss/utilities' important;
.flex-explicitly-important {
  @apply flex!;
}
.flex-not-important {
  @apply flex;
}
```

… would output this:
```css
.flex {
  display: flex !important;
}
.flex-explicitly-important  {
  display: flex !important;
}
.flex-not-important {
  display: flex !important;
}
```

But it's expected that `@apply` doesn't consider the "global" important
state. This PR addresss this problem and now the output is this:

```css
.flex {
  display: flex !important;
}
.flex-explicitly-important  {
  display: flex !important;
}
.flex-not-important {
  display: flex; /* this line changed */
}
```

If you want to mark a utility as important in `@apply` you can still use
`!` after the utility to do so as shown above.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2025-06-27 11:55:15 -04:00
..
codemods Don't consider the global important state in @apply (#18404) 2025-06-27 11:55:15 -04:00
commands/help Add initial codemod tooling (#14434) 2024-09-18 16:45:43 +02:00
utils Improve @tailwindcss/upgrade and pnpm workspaces support (#18065) 2025-05-19 12:47:08 +02:00
index.test.ts Ensure @tailwindcss/upgrade runs on Tailwind CSS v4 projects and is idempotent (#17717) 2025-04-22 11:10:46 -04:00
index.ts Add ignore pattern for node_modules in globby search in upgrade cli (#17969) 2025-05-12 11:09:40 +00:00
stylesheet.ts Ensure @tailwindcss/upgrade runs on Tailwind CSS v4 projects and is idempotent (#17717) 2025-04-22 11:10:46 -04:00