#Tailwind v4
3 messages · Page 1 of 1 (latest)
The issue you're encountering is related to how Tailwind CSS is being integrated with Astro using Vite. Let me clarify a few points and provide a corrected configuration:
-
Tailwind CSS v4 is not yet released. The latest stable version of Tailwind CSS is v3.x.
-
The way you're importing and using the Tailwind CSS plugin for Vite is incorrect in the Astro configuration.
Here's the correct way to set up Tailwind CSS with Astro:
- First, make sure you have installed the official Astro Tailwind integration:
npm install @astrojs/tailwind
- Then, update your Astro configuration as follows:
// @ts-check
import { defineConfig, envField } from "astro/config";
import tailwind from "@astrojs/tailwind";
// <https://astro.build/config>
export default defineConfig({
output: "server",
trailingSlash: "always",
devToolbar: {
enabled: false,
},
server: {
port: 1234,
host: true,
},
env: {
schema: {
AVATAR_DIR_URL: envField.string({
context: "server",
access: "public",
optional: false,
}),
},
},
integrations: [tailwind()],
});
The key changes are:
- Import the Tailwind integration from
@astrojs/tailwindinstead of@tailwindcss/vite. - Use the
integrationsarray in the Astro config to add the Tailwind integration, instead of adding it to the Vite plugins.
This configuration should resolve the type error you were experiencing. The error occurred because you were trying to use the Vite plugin directly, which isn't the recommended way to integrate Tailwind with Astro.