Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Tailwind utility classes not generated in monorepo #17904

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

Closed
falkmatt91 opened this issue May 6, 2025 · 2 comments
Closed

Tailwind utility classes not generated in monorepo #17904

falkmatt91 opened this issue May 6, 2025 · 2 comments

Comments

@falkmatt91
Copy link

Tailwind CSS v4.1.5 Monorepo Issue: Missing Utility Classes in Production Build

Environment Details

What version of Tailwind CSS are you using?

v4.1.5

What build tool (or framework if it abstracts the build tool) are you using?

Next.js 15 with Turbopack

What version of Node.js are you using?

v23

What browser are you using?

Chrome latest

What operating system are you using?

macOS

Monorepo Structure

assetos/
├── apps/
│   └── dashboard/
│       ├── src/
│       │   └── app/
│       │       ├── layout.tsx
│       │       └── globals.css
│       ├── .next/
│       ├── package.json
│       ├── next.config.ts
│       └── Dockerfile.optimized
├── packages/
│   └── ui/
│       ├── src/
│       │   └── theme.css
│       ├── tailwind.config.js
│       ├── postcss.config.mjs
│       └── package.json
├── node_modules/
├── package.json
├── pnpm-workspace.yaml
└── ...

Describe your issue

After upgrading to Tailwind CSS v4.1.5, utility classes are not being generated in the production build, despite following all recommended configurations and best practices. The issue appears to be related to how Tailwind processes files in a monorepo structure.

Current Setup

  1. UI Package (packages/ui):

    • Contains shared UI components and theme
    • Has its own tailwind.config.js (tried as a workaround / fallback - also didn't fix the issue) and postcss.config.mjs
    • Uses @source directives in theme.css to scan both app and UI components
  2. Dashboard App (apps/dashboard):

    • Next.js 15 application
    • Imports UI package and theme
    • Uses Turbopack for development and production builds

Attempted Solutions

  1. Configuration Updates:

    • Updated to latest Tailwind v4.1.5
    • Implemented recommended @source directives
    • Configured proper content paths in tailwind.config.js
    • Added @config directive in theme CSS
  2. Build Process:

    • Verified proper CSS imports in app's globals.css
    • Confirmed correct PostCSS configuration
    • Checked for proper file scanning in development
  3. Monorepo Structure:

    • Ensured proper workspace configuration
    • Verified package dependencies
    • Confirmed correct file paths in configurations

Expected Behavior

Utility classes should be generated and included in the production build, as they are in development.

Actual Behavior

Production build CSS only contains theme variables and base styles, but no utility classes (like .bg-red-500, .text-white, etc.).

Additional Context

This issue appears to be related to how Tailwind v4.1.5 processes files in a monorepo structure, particularly with the @source directive and file path resolution. The problem persists despite following all official documentation and best practices for Tailwind v4 monorepo setups.

Reproduction Steps

tbd

Related Issues

  • Similar issues reported in Tailwind CSS GitHub issues for monorepo setups
  • Potential connection to file path resolution in monorepo structures
@wongjn
Copy link
Collaborator

wongjn commented May 6, 2025

What was the old version of Tailwind CSS before you updated to v4.1.5? Could you also provide a git repo that reproduces the unexpected behavior please?

@falkmatt91
Copy link
Author

sure - old version was "tailwindcss": "^3.4.1" - repo to reproduce: https://github.com/falkmatt91/tailwind-v4

@wongjn wongjn converted this issue into discussion #17905 May 6, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants