Repository navigation
Process Vue <style module> blocks in @tailwindcss/vite - #20597
mkantautas wants to merge 2 commits into
Conversation
WalkthroughThe Vite integration now recognizes both standard CSS and CSS module language queries in its serve and build transform filters and CSS root detection. A production-build test covers Vue Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🔇 Additional comments: 3
packages/@tailwindcss-vite/src/index.ts: 1
21-21: LGTM!Also applies to: 214-214, 251-251, 303-303
CHANGELOG.md: 1
60-60: LGTM!integrations/vite/vue.test.ts: 1
145-145: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Regex depends on the CSS output format and class-name template.
The test sets
cssMinify: falseand asserts a._foo_<hash> {selector. This relies on the default@vitejs/plugin-vueCSS-module naming template. It also relies on Lightning CSS or esbuild keeping thecolor: var(--color-red-500text unchanged.The test passes in the reported run. Keep the assertion if the format is stable across the supported Vite versions. Otherwise, loosen the regex, for example to
/\._foo_[\w-]+\s*\{\s*color:\s*var\(--color-red-500/.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3a74a33e-fbf5-4b5d-ae46-6d563595e7cd
📒 Files selected for processing: 3
CHANGELOG.mdintegrations/vite/vue.test.tspackages/@tailwindcss-vite/src/index.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
[Medium impact] The PR appears safe to merge; no actionable issues were found. Reviews (1) · Last reviewed commit: "Add changelog entry for #20597" · Reviewed by Greptile |
Summary
@vitejs/plugin-vuegives<style module>blocks ids that end in&lang.module.css(e.g.App.vue?vue&type=style&index=0&lang.module.css).isPotentialCssRootFileonly accepts&lang.css, so these blocks are never handed to Tailwind and@reference/@applyend up in the built CSS unprocessed:With Vite 8.3.4,
@vitejs/plugin-vue6.0.10 and@tailwindcss/vite4.3.3 the bundle contains:Plain
<style>and<style scoped>blocks in the same component are processed.This matches
&lang.module.cssin the transform filters and inisPotentialCssRootFile. The Tailwind transform runs withenforce: 'pre', so@applyis expanded beforevite:csshashes the class names.Test plan
production build with <style module> blockstointegrations/vite/vue.test.ts. Onmainit fails because the CSS still contains@apply text-red-500;; with this change it passes and the hashed.foorule hascolor: var(--color-red-500, …).pnpm vitest --root=./integrations run vite/vue.test.ts: 5 passed.pnpm vitest --root=./integrations run vite/: all Vue and CSS modules tests pass. On my machine, dev-server tests that are unrelated to this change (external source file changes update the CSS, react-routerbuild mode) timed out under load.prettier --checkon the changed files.