Skip to content

Some Tailwind classes are not extracted from Pug templates in Vue when elements have attributes #17313

@davidrunger

Description

@davidrunger

What version of Tailwind CSS are you using?

v4.0.15 (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 this bug is particular to 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-attr-bug-demo

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

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">
.text-sky-600.bg-neutral-900(title="A tooltip") This div has an HTML attribute.
</template>

Actual

When viewed in the browser, only the text-sky-600 class has any visible effect (making the text blue). 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).

Image

Expected

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 :

Image

Additional context:

I recently reported a similar bug for this environment (Vue templates using Pug) here: #17211. That was fixed by #17252, which was included in the Tailwind 4.0.15 release today. Although that issue was fixed, this different issue (where the presence of an HTML attribute seems to cause not all Tailwind classes to be extracted from the Pug Vue template) is present in 4.0.15.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions