Skip to content

CSS is not included for some Tailwind classes in Pug template (in Vue) #17211

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

Closed
davidrunger opened this issue Mar 15, 2025 · 2 comments · Fixed by #17252
Closed

CSS is not included for some Tailwind classes in Pug template (in Vue) #17211

davidrunger opened this issue Mar 15, 2025 · 2 comments · Fixed by #17252
Assignees

Comments

@davidrunger
Copy link

davidrunger commented Mar 15, 2025

What version of Tailwind CSS are you using?

v4.0.14 (the latest released version, at the time of writing)

What build tool (or framework if it abstracts the build tool) are you using?

Vite 6.2.2, Vue 3.5.13, Pug 3.0.3 (the latest released version of each, at the time of writing)

What version of Node.js are you using?

v22.14.0 (the latest LTS release, at the time of writing)

What browser are you using?

Firefox (though I don't think it's relevant)

What operating system are you using?

Linux (Debian / MX Linux) (though I don't think it's relevant)

Reproduction URL

I cannot provide a Tailwind Play URL, because I think that this bug occurs only in Pug templates, whereas Tailwind Play only supports plain HTML.

But here's a public GitHub repo with a minimal reproduction: https://github.com/davidrunger/tailwind-pug-bug-demo

And here's that GitHub repo imported into CodeSandbox: https://codesandbox.io/p/github/davidrunger/tailwind-pug-bug-demo/main?file=%2Fsrc%2FApp.vue

Describe your issue

CSS styles are sometimes not included for some Tailwind classes in Pug templates in my Vue project.

In the reproduction linked above, there is this Vue component:

<template lang="pug">
.bg-neutral-900.text-red-500 This is a test.
</template>

When viewed in the browser, only the text-red-500 class has any visible effect (making the text red). The bg-neutral-900 class does not have any effect (when served either via the Vite hot-reloading dev server or when compiled and viewed via the Vite static production preview server).

Live dev server:

Image

Compiled production server:

Image

I expect that the bg-neutral-900 class in the Pug Vue template would cause Tailwind to include CSS that gives that text a dark background, which is what happens if we go back to tailwindcss and @tailwindcss/vite at v4.0.9 :

Live dev server:

Image

Compiled production server:

Image

Thank you for Tailwind and for taking a look at this bug!

Edit: The bug also occurs when using the Tailwind PostCSS plugin, rather than the Tailwind Vite plugin (when using Tailwind v4.0.14, and not when using Tailwind v4.0.9). I pushed a branch use-tailwind-postcss-plugin to the minimal bug reproduction repo that demonstrates this.

@davidrunger davidrunger changed the title CSS is not included for some Tailwind classes in Pug template in Vue project CSS is not included for some Tailwind classes in Pug template (in Vue) Mar 15, 2025
@RobinMalfait RobinMalfait self-assigned this Mar 17, 2025
RobinMalfait added a commit that referenced this issue Mar 17, 2025
This PR fixes an issue where `<template lang="…">…</template>` in Vue
files should be handled as-if it's the language specified in the `lang`
attribute.

To do this, we added a new Vue pre processor and run the content through
the same pre processor logic as we do for other languages.

Fixes: #17211

# Test plan

1. Added a test to verify this works
2. Existing tests still work

Visually verified against the reproduction in the issue:

| Before | After |
| --- | --- |
| <img width="1273" alt="image"
src="https://github.com/user-attachments/assets/d1accdeb-97cf-48ef-83fb-978832b3e599"
/> | <img width="1273" alt="image"
src="https://github.com/user-attachments/assets/ab7ec19c-b6c4-43be-8845-096ff4e58808"
/> |

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
@RobinMalfait
Copy link
Member

Hey!

This has been fixed by #17252 and will be available in the next release.

@davidrunger
Copy link
Author

Wow, thank you for the incredibly quick fix, @RobinMalfait ! 🙇‍♂️ 🙌

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.

2 participants