-
Environment
DescriptionWhen using Tailwind CSS v4 with the Expected BehaviorEach Astro page should receive a CSS bundle containing only:
Example:
Actual BehaviorEvery page receives the same 103KB CSS bundle containing:
Example:
Site exampleSingle basic component |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To achieve that, you'd need separate source CSS files per page. You'd then disable automatic source detection and handpick the files that Tailwind should scan per CSS file (per page). However, I would say this would get unweildy. Rather, The paradigm of Tailwind CSS is to have one global CSS file as you do now. Initially the CSS file size goes up quickly for a project, but after a certain size, the CSS file size mellows out. This is because as a project grows, there is more class reuse. Further, having one CSS file means that only 1 CSS file needs to be downloaded once for the site. The cache could then be used for other page visits. I see you've use compression so the transfer size is only 18KB. |
Beta Was this translation helpful? Give feedback.
-
OK understood. Just wanted to make sure I wasn't missing something obvious. |
Beta Was this translation helpful? Give feedback.
To achieve that, you'd need separate source CSS files per page. You'd then disable automatic source detection and handpick the files that Tailwind should scan per CSS file (per page).
However, I would say this would get unweildy. Rather, The paradigm of Tailwind CSS is to have one global CSS file as you do now. Initially the CSS file size goes up quickly for a project, but after a certain size, the CSS file size mellows out. This is because as a project grows, there is more class reuse. Further, having one CSS file means that only 1 CSS file needs to be downloaded once for the site. The cache could then be used for other page visits. I see you've use compression so the transfer size is on…