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

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

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

jagthedrummer
Copy link
Contributor

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.

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).

…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
Copy link
Contributor Author

I just noticed that the Tailwind docs say that you shouldn't need a preprocessor for variables, so maybe we should remove postcss-css-variables entirely? Or maybe there's a difference between "variables on the web" and "variables in HTML email"?

@jagthedrummer jagthedrummer requested a review from kaspth April 3, 2024 21:22
@@ -7,9 +7,9 @@ module.exports = {
plugins: [
require('postcss-import')(postcssImportConfig),
require('postcss-extend-rule'),
require('postcss-nested'),
require('tailwindcss'),
require('postcss-css-variables'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jagthedrummer according to this caniemail.com report, css variables have bad support among email clients.

So yeah, let's only keep postcss-css-variables for the mailer css, and add a comment about this caniemail.com report for posterity.

Otherwise, LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, idea about linking to that report, @pascallaliberte. Thanks!

@jagthedrummer jagthedrummer merged commit 8a072fd into main Apr 5, 2024
24 checks passed
@jagthedrummer jagthedrummer deleted the jeremy/tailwind-nesting branch April 5, 2024 19:28
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.

tailwindcss v3.4.2 included breaking changes around @apply postcss-css-variables seems less than ideal
3 participants