Skip to content

Commit 89eb1ba

Browse files
authored
Fix Vite serve issues (#13380)
* Temporarily disable waitForRequestIdle * Only apply vite:css-post in build mode
1 parent c815221 commit 89eb1ba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/@tailwindcss-vite/src/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,15 @@ export default function tailwindcss(): Plugin[] {
113113

114114
async configResolved(config) {
115115
minify = config.build.cssMinify !== false
116+
// Apply the vite:css plugin to generated CSS for transformations like
117+
// URL path rewriting and image inlining.
118+
//
119+
// In build mode, since renderChunk runs after all transformations, we
120+
// need to also apply vite:css-post.
116121
cssPlugins = config.plugins.filter((plugin) =>
117-
['vite:css', 'vite:css-post'].includes(plugin.name),
122+
['vite:css', ...(config.command === 'build' ? ['vite:css-post'] : [])].includes(
123+
plugin.name,
124+
),
118125
)
119126
},
120127

@@ -158,9 +165,13 @@ export default function tailwindcss(): Plugin[] {
158165
// In serve mode, we treat cssModules as a set, ignoring the value.
159166
cssModules[id] = ''
160167

168+
// TODO: Re-enable waitForRequestsIdle once issues with it hanging are
169+
// fixed. Until then, this transformation may run multiple times in
170+
// serve mode, possibly giving a FOUC.
171+
//
161172
// Wait until all other files have been processed, so we can extract all
162173
// candidates before generating CSS.
163-
await server?.waitForRequestsIdle?.(id)
174+
// await server?.waitForRequestsIdle?.(id)
164175

165176
let code = await transformWithPlugins(this, id, generateCss(src))
166177
return { code }

0 commit comments

Comments
 (0)