Skip to content

source() handling different between cli and vite #18833

@hyperknot

Description

@hyperknot

What version of Tailwind CSS are you using?

For example: v4.0.6

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

tailwindcss 4.1.12
@tailwindcss/vite 4.1.12

What version of Node.js are you using?
v22.13.1

What browser are you using?

What operating system are you using?

macOS

Describe your issue

The same line

@import "tailwindcss" source("../../components");

works with cli but not with the Vite plugin. Vite says directory doesn't exist.

I'm trying to figure out what is the base directory in Vite plugin, but it's impossible. I enabled DEBUG, but it shows nothing meaningful.

transforming (1) src/index.tsx
[78.23ms] [@tailwindcss/vite] Generate CSS (build)
[77.96ms]   ↳ Setup compiler

✓ 6 modules transformed.
✗ Build failed in 142ms
error during build:
[@tailwindcss/vite:generate:build] The `source(../../components)` does not exist 

Even when it works, it's really not showing anything. The most important information would be:

  • base dir
  • absolute path of the resolved scan target
  • exact file list added by the scanner

Instead, I get this:

transforming (7) ../packages/shared/components/AppUI.tsx
[163.03ms] [@tailwindcss/vite] Generate CSS (build)
[ 81.87ms]   ↳ Setup compiler
[  3.72ms]   ↳ Setup scanner
[ 14.76ms]   ↳ Scan for candidates
[ 14.70ms]   ↳ Build CSS
[  0.00ms]   ↳ Build Source Map
[ 12.48ms] [@tailwindcss/vite] Optimize CSS

Right now, I'm at the step when I'm recompiling tailwind/vite to add these debug lines.

So please take this as both a bug report and a feature request.

  1. Bug: cli can compile a file that vite cannot.
  2. Feature request: allow users to see what's happening, otherwise configuring source() is totally walking in the dark.

Metadata

Metadata

Assignees

Labels

oxideIssues affecting file parsing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions