I am trying to deploy an Astro.js site on Vercel that utilizes TailwindCSS v4:
tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
purge: ["./src/pages/**/*.{js,ts,jsx,tsx}", "./src/Components/**/*. {js,ts,jsx,tsx}"],
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
};
astro.config.js
// @ts-check
import { defineConfig, fontProviders } from 'astro/config';
import playformCompress from '@playform/compress';
import react from "@astrojs/react";
import vercel from '@astrojs/vercel';
import tailwindcss from "@tailwindcss/vite";
// https://astro.build/config
export default defineConfig({
prefetch: {
prefetchAll: false
},
vite: {
css: {
transformer: "lightningcss"
},
build: {
cssMinify: 'lightningcss'
},
plugins: [tailwindcss()]
},
integrations: [react(), playformCompress()],
experimental: {
fonts: [{
provider: fontProviders.google(),
name: "Geist",
cssVariable: "--font-geist",
fallbacks: ["Inter", "sans-serif"],
}]
},
output: 'server',
adapter: vercel(),
});
On a local build using npm run build works perfectly fine in every case. On Vercel I set the following commands for dependency install and build:
npm install
npm run build
I set the default output directory to ./dist. Whenever I deploy to Vercel on production Tailwind seems to break completely and I am not sure why there would be a difference. When I run local build I do notice that static files are placed in .vercel/output.static/, but I am not sure if this exactly makes a difference as I have tried setting the default output path to there and I still see the same broken CSS.