Skip to content

feat: add Vite 7 support to the @tailwindcss/vite plugin #18384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add heuristic to skip candidate migrations inside `emit(…)` ([#18330](https://github.com/tailwindlabs/tailwindcss/pull/18330))
- Extract candidates with variants in Clojure/ClojureScript keywords ([#18338](https://github.com/tailwindlabs/tailwindcss/pull/18338))
- Document `--watch=always` in the CLI's usage ([#18337](https://github.com/tailwindlabs/tailwindcss/pull/18337))
- Add support for Vite 7 to `@tailwindcss/vite` ([#18384](https://github.com/tailwindlabs/tailwindcss/pull/18384))

## [4.1.10] - 2025-06-11

Expand Down
8 changes: 4 additions & 4 deletions integrations/vite/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -76,7 +76,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -140,7 +140,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -219,7 +219,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/css-modules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/html-style-blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test(
},
"devDependencies": {
"@tailwindcss/vite": "workspace:^",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/ignored-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const WORKSPACE = {
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
18 changes: 9 additions & 9 deletions integrations/vite/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -111,7 +111,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -312,7 +312,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -491,7 +491,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -577,7 +577,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -679,7 +679,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -744,7 +744,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -816,7 +816,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -879,7 +879,7 @@ test(
"@tailwindcss/vite": "workspace:^",
"tailwindcss": "workspace:^",
"plotly.js": "^3",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
4 changes: 2 additions & 2 deletions integrations/vite/multi-root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -96,7 +96,7 @@ test(
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/other-transforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {
},
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/source-maps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test(
},
"devDependencies": {
"lightningcss": "^1",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
47 changes: 47 additions & 0 deletions integrations/vite/ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,50 @@ test(
])
},
)

test(
`Vite 7`,
{
fs: {
'package.json': json`
{
"type": "module",
"dependencies": {
"@tailwindcss/vite": "workspace:^",
"tailwindcss": "workspace:^"
},
"devDependencies": {
"vite": "^7"
}
}
`,
'vite.config.ts': ts`
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
build: {
cssMinify: false,
ssrEmitAssets: true,
},
plugins: [tailwindcss()],
})
`,
...WORKSPACE,
},
},
async ({ fs, exec, expect }) => {
await exec('pnpm vite build --ssr server.ts')

let files = await fs.glob('dist/**/*.css')
expect(files).toHaveLength(1)
let [filename] = files[0]

await fs.expectFileToContain(filename, [
candidate`underline`,
candidate`m-2`,
candidate`overline`,
candidate`m-3`,
])
},
)
4 changes: 2 additions & 2 deletions integrations/vite/svelte.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test(
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5",
"@tailwindcss/vite": "workspace:^",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -125,7 +125,7 @@ test(
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5",
"@tailwindcss/vite": "workspace:^",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/url-rewriting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe.each(['postcss', 'lightningcss'])('%s', (transformer) => {
"devDependencies": {
${transformer === 'lightningcss' ? `"lightningcss": "^1",` : ''}
"@tailwindcss/vite": "workspace:^",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
4 changes: 2 additions & 2 deletions integrations/vite/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test(
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.2",
"@tailwindcss/vite": "workspace:^",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down Expand Up @@ -87,7 +87,7 @@ test(
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.2",
"@tailwindcss/vite": "workspace:^",
"vite": "^6"
"vite": "^7"
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion packages/@tailwindcss-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"vite": "catalog:"
},
"peerDependencies": {
"vite": "^5.2.0 || ^6"
"vite": "^5.2.0 || ^6 || ^7"
}
}
4 changes: 2 additions & 2 deletions packages/tailwindcss/src/at-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ test('@layer', async () => {
})

test('supports theme(reference) imports', async () => {
expect(
await expect(
run(
css`
@tailwind utilities;
Expand Down Expand Up @@ -542,7 +542,7 @@ test('it crashes when inside a cycle', async () => {
base: '/root',
})

expect(
await expect(
run(
css`
@import 'foo.css';
Expand Down
18 changes: 9 additions & 9 deletions packages/tailwindcss/src/css-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('--alpha(…)', () => {
})

test('--alpha(…) errors when no arguments are used', async () => {
expect(() =>
await expect(() =>
compileCss(css`
.foo {
margin: --alpha();
Expand All @@ -35,7 +35,7 @@ describe('--alpha(…)', () => {
})

test('--alpha(…) errors when alpha value is missing', async () => {
expect(() =>
await expect(() =>
compileCss(css`
.foo {
margin: --alpha(red);
Expand All @@ -47,7 +47,7 @@ describe('--alpha(…)', () => {
})

test('--alpha(…) errors multiple arguments are used', async () => {
expect(() =>
await expect(() =>
compileCss(css`
.foo {
margin: --alpha(red / 50%, blue);
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('--spacing(…)', () => {
})

test('--spacing(…) relies on `--spacing` to be defined', async () => {
expect(() =>
await expect(() =>
compileCss(css`
.foo {
margin: --spacing(4);
Expand All @@ -113,7 +113,7 @@ describe('--spacing(…)', () => {
})

test('--spacing(…) requires a single value', async () => {
expect(() =>
await expect(() =>
compileCss(css`
@theme {
--spacing: 0.25rem;
Expand All @@ -129,7 +129,7 @@ describe('--spacing(…)', () => {
})

test('--spacing(…) does not have multiple arguments', async () => {
expect(() =>
await expect(() =>
compileCss(css`
.foo {
margin: --spacing(4, 5, 6);
Expand Down Expand Up @@ -364,7 +364,7 @@ describe('--theme(…)', () => {
})

test('--theme(…) can only be used with CSS variables from your @theme', async () => {
expect(() =>
await expect(() =>
compileCss(css`
@theme {
--color-red-500: #f00;
Expand All @@ -377,7 +377,7 @@ describe('--theme(…)', () => {
`[Error: The --theme(…) function can only be used with CSS variables from your theme.]`,
)

expect(() =>
await expect(() =>
compileCss(css`
@theme {
--color-red-500: #f00;
Expand Down Expand Up @@ -789,7 +789,7 @@ describe('theme(…)', () => {
})

test('theme(colors.unknown.500)', async () =>
expect(() =>
await expect(() =>
compileCss(css`
.red {
color: theme(colors.unknown.500);
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4363,7 +4363,7 @@ test('addBase', async () => {
})

it("should error when `layer(…)` is used, but it's not the first param", async () => {
expect(async () => {
await expect(async () => {
return await compileCss(
css`
@import './bar.css' supports(display: grid) layer(utilities);
Expand Down
Loading