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

tailwindcss v3.4.2 included breaking changes around @apply #1416

Closed
jagthedrummer opened this issue Apr 2, 2024 · 1 comment · Fixed by #1417
Closed

tailwindcss v3.4.2 included breaking changes around @apply #1416

jagthedrummer opened this issue Apr 2, 2024 · 1 comment · Fixed by #1417

Comments

@jagthedrummer
Copy link
Contributor

In #1386 @depfu tried to update tailwindcss to version 3.4.2 and CI is failing for that PR with this error.

CssSyntaxError: .../bullet_train-themes-light-1.6.38/app/assets/stylesheets/light/tailwind/components.css:179:5:
  The `button-alternative` class cannot be used with `@apply` because `@apply` does
  not currently support nested CSS.
  Rewrite the selector without nesting or configure the `tailwindcss/nesting` plugin:
  https://tailwindcss.com/docs/using-with-preprocessors#nesting

  at .../bullet_train-themes-light-1.6.38/app/assets/stylesheets/light/tailwind/components.css:42:5

The issue seems to be that the @apply directive was updated here: tailwindlabs/tailwindcss#13325

Given that this happened in a patch level version bump it seems like we might be hitting unexpected breakage, so I've opened an issue on the tailwind repo: tailwindlabs/tailwindcss#13433

Hopefully this is a bug that can be resolved on the tailwind side. If not we may need to rewrite some CSS in order to upgrade tailwindcss past version 3.4.1 (the last version that doesn't throw this error during the build step).

@jagthedrummer
Copy link
Contributor Author

Turns out it's not a tailwind bug, we just need to activate the tailwindcss/nesting plugin. tailwindlabs/tailwindcss#13433 (comment)

jagthedrummer added a commit that referenced this issue Apr 3, 2024
…ables

Fixes #1416
Fixes #1074

As noted in #1416 there's been a change in `tailwindcss` around the
`@apply` directive. In order to get it to work correctly for nested
classes we need to use the `tailswindcss/nesting` plugin. We were already
using `postcss-nested`, which is what `tailwindcss/nesting` uses under
the hood. So this PR just switches them out.

It also moves the `postcss-css-variables` plugin to be higher in the
plugin stack for the mailer stylesheet. [That plugin doesn't play nicely
when it's below the nesting plugin.](MadLittleMods/postcss-css-variables#135 (comment))

Moving `postcss-css-variables` higher in the stack also seems to have
fixed the problems described in #1074. When it's higher in the stack I
see almost zero difference in build times between having it activated or
not, and the resulting stylesheet is actually _smaller_ when it is
activated (~120k vs ~140k).
jagthedrummer added a commit that referenced this issue Apr 5, 2024
…ables (#1417)

* Update tailwind, switch to tailwindcss/nesting, move postcss-css-variables

Fixes #1416
Fixes #1074

As noted in #1416 there's been a change in `tailwindcss` around the
`@apply` directive. In order to get it to work correctly for nested
classes we need to use the `tailswindcss/nesting` plugin. We were already
using `postcss-nested`, which is what `tailwindcss/nesting` uses under
the hood. So this PR just switches them out.

It also moves the `postcss-css-variables` plugin to be higher in the
plugin stack for the mailer stylesheet. [That plugin doesn't play nicely
when it's below the nesting plugin.](MadLittleMods/postcss-css-variables#135 (comment))

Moving `postcss-css-variables` higher in the stack also seems to have
fixed the problems described in #1074. When it's higher in the stack I
see almost zero difference in build times between having it activated or
not, and the resulting stylesheet is actually _smaller_ when it is
activated (~120k vs ~140k).

* Add a link to a report about variable support in email clients
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant