mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Closes #18381 * [Changelog for Vite 7.0.0 (2025-06-24)](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#700-2025-06-24) Starting from Vite 7, Node 18 support will be dropped, which doesn't really affect Tailwind. It might be worth mentioning in the documentation that the recommended minimum Node versions are 20.19 and 22.12. Vite 7 is only available in ESM format, which is also not an issue. Vite's browser support aligns with the v4 guidelines: ``` Chrome 87 → 107 (tw: 111) Edge 88 → 107 (tw: 111) Firefox 78 → 104 (tw: 128) Safari 14.0 → 16.0 (tw: 16.4) ``` * [Vite 7 - Browser Support](https://vite.dev/guide/migration.html#default-browser-target-change) * [Tailwind CSS v4 - Browser Support](https://tailwindcss.com/docs/compatibility#browser-support) So, at first glance, there's nothing more to do except enabling support for these versions. --------- Co-authored-by: Jordan Pittman <jordan@cryptica.me>
147 lines
3.7 KiB
TypeScript
147 lines
3.7 KiB
TypeScript
import { stripVTControlCharacters } from 'node:util'
|
|
import { candidate, html, json, test, ts } from '../utils'
|
|
|
|
test(
|
|
'production build',
|
|
{
|
|
fs: {
|
|
'package.json': json`
|
|
{
|
|
"type": "module",
|
|
"dependencies": {
|
|
"vue": "^3.4.37",
|
|
"tailwindcss": "workspace:^"
|
|
},
|
|
"devDependencies": {
|
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
"@tailwindcss/vite": "workspace:^",
|
|
"vite": "^7"
|
|
}
|
|
}
|
|
`,
|
|
'vite.config.ts': ts`
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
export default defineConfig({
|
|
plugins: [vue(), tailwindcss()],
|
|
})
|
|
`,
|
|
'index.html': html`
|
|
<!doctype html>
|
|
<html>
|
|
<body>
|
|
<div id="app"></div>
|
|
<script type="module" src="./src/main.ts"></script>
|
|
</body>
|
|
</html>
|
|
`,
|
|
'src/main.ts': ts`
|
|
import { createApp } from 'vue'
|
|
import App from './App.vue'
|
|
|
|
createApp(App).mount('#app')
|
|
`,
|
|
'src/App.vue': html`
|
|
<style>
|
|
@import 'tailwindcss';
|
|
.foo {
|
|
@apply text-red-500;
|
|
}
|
|
</style>
|
|
<style scoped>
|
|
@import 'tailwindcss' reference;
|
|
:deep(.bar) {
|
|
color: red;
|
|
}
|
|
</style>
|
|
<template>
|
|
<div class="underline foo bar">Hello Vue!</div>
|
|
</template>
|
|
`,
|
|
},
|
|
},
|
|
async ({ fs, exec, expect }) => {
|
|
await exec('pnpm vite build')
|
|
|
|
let files = await fs.glob('dist/**/*.css')
|
|
expect(files).toHaveLength(1)
|
|
|
|
await fs.expectFileToContain(files[0][0], [candidate`underline`, candidate`foo`])
|
|
await fs.expectFileToContain(files[0][0], ['.bar{'])
|
|
},
|
|
)
|
|
|
|
test(
|
|
'error when using `@apply` without `@reference`',
|
|
{
|
|
fs: {
|
|
'package.json': json`
|
|
{
|
|
"type": "module",
|
|
"dependencies": {
|
|
"vue": "^3.4.37",
|
|
"tailwindcss": "workspace:^"
|
|
},
|
|
"devDependencies": {
|
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
"@tailwindcss/vite": "workspace:^",
|
|
"vite": "^7"
|
|
}
|
|
}
|
|
`,
|
|
'vite.config.ts': ts`
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
export default defineConfig({
|
|
plugins: [vue(), tailwindcss()],
|
|
})
|
|
`,
|
|
'index.html': html`
|
|
<!doctype html>
|
|
<html>
|
|
<body>
|
|
<div id="app"></div>
|
|
<script type="module" src="./src/main.ts"></script>
|
|
</body>
|
|
</html>
|
|
`,
|
|
'src/main.ts': ts`
|
|
import { createApp } from 'vue'
|
|
import App from './App.vue'
|
|
|
|
createApp(App).mount('#app')
|
|
`,
|
|
'src/App.vue': html`
|
|
<template>
|
|
<div class="foo">Hello Vue!</div>
|
|
</template>
|
|
|
|
<style>
|
|
.foo {
|
|
@apply text-red-500;
|
|
}
|
|
</style>
|
|
`,
|
|
},
|
|
},
|
|
async ({ exec, expect }) => {
|
|
expect.assertions(1)
|
|
|
|
try {
|
|
await exec('pnpm vite build')
|
|
} catch (error) {
|
|
let [, message] =
|
|
/error during build:([\s\S]*?)file:/g.exec(
|
|
stripVTControlCharacters(error.message.replace(/\r?\n/g, '\n')),
|
|
) ?? []
|
|
expect(message.trim()).toMatchInlineSnapshot(
|
|
`"[@tailwindcss/vite:generate:build] Cannot apply unknown utility class \`text-red-500\`. Are you using CSS modules or similar and missing \`@reference\`? https://tailwindcss.com/docs/functions-and-directives#reference-directive"`,
|
|
)
|
|
}
|
|
},
|
|
)
|