Tailwind styles don't apply although fetched on hitting the endpoint

I have my project running just fine during development, and the styles also build fine during production.
But they don’t apply at all on hitting the deployment endpoint at all even though it fetches the file
PS: i’m using @apply for most of my classes(not all/it’s a mix of @apply and regular utility classes).
I have my styles stored in /styles/globals.css and have imported it inside the root layout like this:

import "@/styles/globals.css";

NextJS v15.1.6
Tailwind CSS v3.4.17
Vercel

Here’s the Tailwind config

import type { Config } from "tailwindcss";

export default {
  content: [
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
    "./pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./components/**/*.{js,ts,jsx,tsx,mdx}",
    "./index.html",
  ],
  theme: {
    extend: {
      fontFamily: {
        quicksand: ["var(--font-quicksand)"],
      },
    },
  },
  plugins: [],
} satisfies Config;

and here’s the Next config:

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  compress: true,
  devIndicators: {
    buildActivity: false,
    appIsrStatus: false,
  },
  images: {
    dangerouslyAllowSVG: true,
    remotePatterns: [
      ...
    ],
  },
};

export default nextConfig;

Here’s the link: Production build

Hi @tejas-git64, welcome to the Vercel Community!

Sorry that you’re facing this issue. Are you importing Tailwindcss in the global styles file? I’d recommend following the Install Tailwind CSS with Next.js - Tailwind CSS guide, it should solve the issue.

Hi Anshuman,
The @import 'tailwindcss' directive does not work for v3.4, Vercel immediately gives a deployment error on applying that

Hi @tejas-git64, my bad. I shared the link to v4 Tailwind docs. Try this instead: Install Tailwind CSS with Next.js - Tailwind CSS

Tried the exact same steps and it still does not work

Oh, sorry to hear that. Can you share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.

Sure here’s my public repo: GitHub - tejas-git64/BingeTown at next
Branch: next

Hey Anshuman, did you figure something out with the provided repo?

Hi @tejas-git64, sorry for the late reply. But, I couldn’t run the repo locally because it depends on Firebase. Can you make a minimal reproducible example?

One thing I noticed is that the css that comes in your deployment doesn’t contain TailwindCSS. So, the best way to debug this to ensure that the output of next build includes TailwindCSS in the .css file.

You can try creating a new project following the Install Tailwind CSS with Next.js - Tailwind CSS guide and then compare with your projects the dependencies and structure.

Hi @anshumanb , i cannot give an exact minimal reproducible code for the underlying issue, however i somehow found a solution.

I’ll give you a flow of the things i did:

  • Created the initial scaffold with tailwindcss(opted-in)
    This however installed v4 which had issues with the @apply directive

  • Uninstalled tailwindcss from the packages and reinstalled v3. This however still proved to be useless although the deployment build did spit out tailwindcss classes like below:

  • As a last effort i created a new next project but didn’t install tailwindcss during the opt-in step, instead i did that seperately. This worked!! (note this is for v3)

My assumption is that there must have been some package conflict tailwindcss and next due to uninstallation, which the seperate installation might’ve prevented.

Can you guys provide a version specific flag for the packages you recommend to install, to reduce unnecessary conflict?, so that we could choose specific versions to ensure stability?

2 Likes

Hi @tejas-git64, thanks for sharing your solution with the community. I’ll forward your feedback to the team.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.