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

Tailwind should throw an error when trying to @apply group #4553

Closed
andrewtannernumiko opened this issue Jun 2, 2021 · 3 comments · Fixed by #4666
Closed

Tailwind should throw an error when trying to @apply group #4553

andrewtannernumiko opened this issue Jun 2, 2021 · 3 comments · Fixed by #4666

Comments

@andrewtannernumiko
Copy link

I'm flagging a potential addition to documentation as my team have discovered our production builds are growing considerably when using @apply group.

For example:

.button--primary {
  @apply group;
  @apply ...
}

and then another similar .button--secondary also using @apply group is resulting in a very large production file at ~1.8MB. All production settings such as PurgeCSS and minification were being respected so no problem there. Having removed @apply group (and just adding it directly to the component in the HTML) means our builds are now coming out at ~166KB - so a massive improvement!

So I am wondering if this is something worth flagging specifically in the documentation around the group-hover and group-focus variants, that usage of @apply group will inflate builds? The documentation does mention filesize considerations so this might already be deemed sufficient. Equally I might have just overlooked something. Any guidance appreciated - thanks.

@adamwathan
Copy link
Member

Hey! Yeah you definitely do not want to apply group as it won't do what you think it will. It makes sense when you think hard about it though, check this for more information:

#2848 (comment)

I think the best move here is probably to build in an explicit error for this in Tailwind so the build fails. I'll move this to the Tailwind repo 👍🏻

@adamwathan adamwathan transferred this issue from tailwindlabs/tailwindcss.com Jun 3, 2021
@adamwathan adamwathan changed the title '@apply group' impact on production builds. Tailwind should throw an error when trying to @apply group Jun 3, 2021
@andrewtannernumiko
Copy link
Author

andrewtannernumiko commented Jun 4, 2021

Hello! Yeah it makes total sense and was the reason I didn't flag as a bug. Thanks for sharing the link to the other issue. I will have a read 👍 Solution sounds good.

@christhofer
Copy link

christhofer commented Jun 23, 2021

I noticed that this also applies for @apply peer;.
Might as well throw an error for that too.

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 a pull request may close this issue.

3 participants