-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We noticed that Nuxt projects were not working with the tailwindcss project. The issue was traced down to the fact that Nuxt starts multiple Vite dev servers and calling the experimental `waitForRequestsIdle()` on one of the test servers would never resolve. This was fixed upstream and is part of the latest Vite/Nuxt release: vitejs/vite#17980. We still need to handle the fact that Vite can spawn multiple dev servers. This is necessary because when we invalidate all roots, we need to find that module inside all of the spawned servers. If we only look at the _last server_ (what we have done before), we would not find the module and thus could not invalidate it.
- Loading branch information
1 parent
e7ca667
commit 719a535
Showing
3 changed files
with
96 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { expect } from 'vitest' | ||
import { candidate, css, fetchStyles, html, json, retryAssertion, test, ts } from '../utils' | ||
|
||
test( | ||
'dev mode', | ||
{ | ||
fs: { | ||
'package.json': json` | ||
{ | ||
"type": "module", | ||
"dependencies": { | ||
"@tailwindcss/vite": "workspace:^", | ||
"nuxt": "^3.13.1", | ||
"tailwindcss": "workspace:^", | ||
"vue": "latest" | ||
} | ||
} | ||
`, | ||
'nuxt.config.ts': ts` | ||
import tailwindcss from '@tailwindcss/vite' | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
vite: { | ||
plugins: [tailwindcss()], | ||
}, | ||
css: ['~/assets/css/main.css'], | ||
devtools: { enabled: true }, | ||
compatibilityDate: '2024-08-30', | ||
}) | ||
`, | ||
'app.vue': html` | ||
<template> | ||
<div class="underline">Hello world!</div> | ||
</template> | ||
`, | ||
'assets/css/main.css': css`@import 'tailwindcss';`, | ||
}, | ||
}, | ||
async ({ fs, spawn, getFreePort }) => { | ||
let port = await getFreePort() | ||
await spawn(`pnpm nuxt dev --port ${port}`) | ||
|
||
await retryAssertion(async () => { | ||
let css = await fetchStyles(port) | ||
expect(css).toContain(candidate`underline`) | ||
}) | ||
|
||
await fs.write( | ||
'app.vue', | ||
html` | ||
<template> | ||
<div class="underline font-bold">Hello world!</div> | ||
</template> | ||
`, | ||
) | ||
await retryAssertion(async () => { | ||
let css = await fetchStyles(port) | ||
expect(css).toContain(candidate`underline`) | ||
expect(css).toContain(candidate`font-bold`) | ||
}) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters