Skip to content

plugin:@tailwindcss/vite fails to resolve css file import in same folder if not prefixed with ./ #19719

@caalador

Description

@caalador

What version of Tailwind CSS are you using?

"@tailwindcss/vite": "^4.2.1",
"tailwindcss": "^4.2.1",

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

"vite": "^7.3.1"

What version of Node.js are you using?

Node v24.6.0
Npm 11.5.1

What browser are you using?

Browser doesn't matter as it's the plugin:@tailwindcss/vite:generate:serve that fails.

What operating system are you using?

Windows, OSX

Reproduction URL

https://github.com/caalador/tailwind-import-failure

steps to reproduce:
npm install
npm run dev

open page to get internal error.
To fix project add ./ to styles.css components.css import

Describe your issue

When building a project with css containing imports that are from the same directory, but are not prepended with ./ so like @import './my-import.css'; but written as @import 'my-import.css'; the vite plugin fails to find the imported class and fails with

13.01.24 [vite] (client) Pre-transform error: Can't resolve 'components.css' in 'C:\...\Code\Bugs\tailwind\src'
  Plugin: @tailwindcss/vite:generate:serve
  File: C:/.../Code/Bugs/tailwind/src/style.css

Expectation would be that file in same directory would be found and not throw an exception.

This issue has come up with many users as the expectation is that it would be searched from the same folder as the requesting file as this works with normal vite.
Some css with imports are in external projects where the import can not be manually fixed by the developer using the add-on.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions