Description
Version
@tailwindcss/postcss^4.0.0-alpha.25
& tailwindcss^4.0.0-alpha.25
, i.e all versions of v4 alpha from 25 to 33 (as of this writing).
Environment
Output of npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite,tailwindcss,@tailwindcss/postcss}"
:
System:
OS: Linux 6.6 Arch Linux
CPU: (4) x64 Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
Memory: 6.01 GB / 15.57 GB
Container: Yes
Shell: 3.7.1 - /usr/bin/fish
Binaries:
Node: 22.11.0 - ~/.volta/tools/image/node/22.11.0/bin/node
npm: 10.9.0 - ~/.volta/tools/image/node/22.11.0/bin/npm
pnpm: 9.12.3 - ~/.volta/bin/pnpm
Browsers:
Chromium: 130.0.6723.116
npmPackages:
@sveltejs/adapter-auto: ^3.0.0 => 3.3.1
@sveltejs/kit: ^2.0.0 => 2.8.0
@sveltejs/vite-plugin-svelte: ^4.0.0 => 4.0.0
@tailwindcss/postcss: 4.0.0-alpha.25 => 4.0.0-alpha.25
svelte: ^5.0.0 => 5.1.15
tailwindcss: 4.0.0-alpha.25 => 4.0.0-alpha.25
vite: ^5.0.3 => 5.4.11
Reproduction
https://github.com/vnphanquang/sveltekit-tailwind-4-reproduction. Please see README for steps.
Description
Note
Please note that tailwind is being used as a postcss
plugin here, reported issue is not observed when using vite
plugin.
In the reproduction, any svelte
file with a style
tag will cause the following two warnings from svelte-preprocess
during both dev
and build
:
[vite-plugin-svelte] [...truncated_path...]/*.svelte svelte.preprocess returned this file as a dependency of itself. This can be caused by an invalid configuration or importing generated code that depends on .svelte files (eg. tailwind base css)
There have been instances where similar warning was observed: sveltejs/svelte-preprocess#619, sveltejs/svelte-preprocess#346. But I don't exactly know what is causing this now. I'm guessing parsing style
tags calls for parsing Tailwind entry css, which in turns requires parsing all matching source files 🔄.
[...truncated_path...]/*.svelte svelte.preprocess depends on more than 10 external files which can cause slow builds and poor DX, try to reduce them. Found: [list_of_all_source_files_except_raster_images]
Similarly, this is causing a lot of parsing during dev. In our real project with lots of such svelte files, the server quickly crashed with Maximum Call Stack Size Exceeded
.
Use case
Hi all thanks for the good work, Tailwind 4 has been really good and I'm trying to test it out on some existing v3 projects with relatively complex setup. In our case we use tailwind as a postcss plugin because we also rely on some other postcss plugins (mixins, custom properties, custom media queries). We tried to use tailwind as vite plugin which works well in dev but the plugins do not apply during production build.