Skip to content

Commit 2ed4bd9

Browse files
florian-lefebvreHiDeoosarah11918
authored
feat(tailwind): support v4 (#13049)
Co-authored-by: HiDeoo <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]>
1 parent db252e0 commit 2ed4bd9

40 files changed

+547
-265
lines changed

.changeset/curvy-penguins-act.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@astrojs/tailwind': major
3+
---
4+
5+
Deprecates the integration
6+
7+
Tailwind CSS now offers a Vite plugin which is the preferred way to use Tailwind 4 in Astro. Please uninstall `@astrojs/tailwind` and follow the [Tailwind documentation for manual installation](https://tailwindcss.com/docs/installation/framework-guides/astro).
8+
9+
This updated major version is only provided as a convenience for existing projects until they are able to migrate to the new plugin. It offers no additional functionality and is no longer recommended, but may continue to be used in your projects until it is removed entirely.

.changeset/four-chairs-exercise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Updates `astro add tailwind` to add the `@tailwindcss/vite` plugin instead of the `@astrojs/tailwind` integration
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// @ts-check
22
import { defineConfig } from 'astro/config';
3-
import tailwind from '@astrojs/tailwind';
3+
import tailwindcss from '@tailwindcss/vite';
44

55
// https://astro.build/config
66
export default defineConfig({
7-
integrations: [tailwind()],
7+
vite: {
8+
plugins: [tailwindcss()]
9+
}
810
});

examples/with-tailwindcss/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
},
1212
"dependencies": {
1313
"@astrojs/mdx": "^4.0.7",
14-
"@astrojs/tailwind": "^5.1.5",
14+
"@tailwindcss/vite": "^4.0.0",
1515
"@types/canvas-confetti": "^1.9.0",
1616
"astro": "^5.1.10",
17-
"autoprefixer": "^10.4.20",
1817
"canvas-confetti": "^1.9.3",
19-
"postcss": "^8.5.1",
20-
"tailwindcss": "^3.4.17"
18+
"tailwindcss": "^4.0.0"
2119
}
2220
}

examples/with-tailwindcss/src/layouts/main.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import '../styles/global.css';
23
const { content } = Astro.props;
34
---
45

examples/with-tailwindcss/src/pages/index.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import '../styles/global.css';
23
// Component Imports
34
import Button from '../components/Button.astro';
45
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "tailwindcss";

examples/with-tailwindcss/tailwind.config.cjs

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/astro/e2e/fixtures/tailwindcss/astro.config.mjs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import { fileURLToPath } from 'node:url';
2-
import tailwind from '@astrojs/tailwind';
31
import { defineConfig } from 'astro/config';
2+
import tailwindcss from '@tailwindcss/vite';
43

54
// https://astro.build/config
65
export default defineConfig({
7-
integrations: [
8-
tailwind({
9-
configFile: fileURLToPath(new URL('./tailwind.config.js', import.meta.url)),
10-
applyBaseStyles: false
11-
}),
12-
],
136
devToolbar: {
147
enabled: false,
158
},
169
vite: {
10+
plugins: [tailwindcss()],
1711
build: {
1812
assetsInlineLimit: 0,
1913
},

packages/astro/e2e/fixtures/tailwindcss/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"private": true,
55
"dependencies": {
66
"@astrojs/tailwind": "workspace:*",
7+
"@tailwindcss/vite": "^4.0.0",
78
"astro": "workspace:*",
8-
"autoprefixer": "^10.4.20",
9-
"postcss": "^8.5.1",
10-
"tailwindcss": "^3.4.17"
9+
"tailwindcss": "^4.0.0"
1110
}
1211
}

0 commit comments

Comments
 (0)