-
I migrated a Svelte application to Tailwind 4, using @reference where needed in <style> blocks, nearly 50 components. I have a base css that imports tailwind css, an external theme and some custom utility classes. It is referenced as
Now building the app is very slow, times doubled from less than 30 seconds to more than 60, but even during development a change to a utility class is applied to the web page after many seconds. I read that for every @reference the full css is rebuilt and the use of <style> blocks is discouraged (I do not agree with that, in Svelte this is a fundamental concept), but the whole process seems really too slow. Has anyone a suggestion to speed things up? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
You could consider not using As per the aforementioned Twitter thread, using Edit#17836 may improve performance in this case. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, after the update to Tailwind 4 in SvelteKit, it is not very usable. DX is very weak, you have to write Tailwind in combination with |
Beta Was this translation helpful? Give feedback.
-
I tried the workaround suggested here #17693 and it seems to work in my case. Build time is halved and during development HMR is almost as fast as before. So this is possible. I think this should be applied automatically by Tailwind when using |
Beta Was this translation helpful? Give feedback.
-
I am facing same issue. Workaround suggest by @ff-ils is not working (doesn't seem to be a valid syntax). Manually replacing all occurrences of @apply to not use @reference is not feasible as there are over 600 occurrences of @apply in my project and I added @referece using a script to make them work. Has anyone managed to fix it ? |
Beta Was this translation helpful? Give feedback.
-
This is my configuration:
I use svelte-preprocess in order to add
app.css is imported by the root +layout.svelte file.
and common.css contains my custom theme, some global classes and Tailwind utilities. |
Beta Was this translation helpful? Give feedback.
-
Latest release 4.1.6 includes #17836 that solves the problem. I rolled back the workaround and build times are ok. |
Beta Was this translation helpful? Give feedback.
Latest release 4.1.6 includes #17836 that solves the problem. I rolled back the workaround and build times are ok.