Skip to content

No classes generated in monorepo setup with Yarn PnP #17739

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

Open
Wroud opened this issue Apr 22, 2025 · 4 comments
Open

No classes generated in monorepo setup with Yarn PnP #17739

Wroud opened this issue Apr 22, 2025 · 4 comments

Comments

@Wroud
Copy link

Wroud commented Apr 22, 2025

What version of Tailwind CSS are you using?

v4.0.8 / v4.1+

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

Vite 6.1+

What version of Node.js are you using?

v22

What browser are you using?

Chrome latest

What operating system are you using?

macOS

Reproduction URL

https://github.com/Wroud/tailwindcss-yarn-pnp

Describe your issue

I think that this problem is because yarn pnp doesn't use real file system paths, insted it will be something like:

/Users/user/Documents/working-repo/.yarn/__virtual__/@wroud-vite-plugin-playground-virtual-7ef94fc781/1/packages/@wroud/vite-plugin-playground/src/app/components/Layout.css

@source also doesn't work (before v4.1 version it's possible to use absolute paths, but they also not work after v4.1)

this setup works well on 4.0.7 version and broken after 88b762b#diff-00d01a2d38f5f4253651cf9811eab1182c96f0307e78c567b803416e24b98165

@bjornars
Copy link

I can confirm that this monorepo (using vike, but also reproed with vanilla vite) setup is also broken using npm workspaces. It works when reverting to 4.0.7

https://github.com/bjornars/vike-tailwind-workspace-repro

@Wroud
Copy link
Author

Wroud commented Apr 22, 2025

@bjornars
Copy link

@bjornars probably you can try to use @source directive https://tailwindcss.com/docs/functions-and-directives#source-directive

https://tailwindcss.com/docs/detecting-classes-in-source-files#setting-your-base-path

Thanks, that worked 👍 Sorry for derailing your issue.

@wongjn
Copy link
Collaborator

wongjn commented Apr 24, 2025

I think this may be due to #16631 that was released in v4.0.8. This PR changes the Vite such that it changes the Tailwind class scanning from using Vite's module graph code to using the file system.

With my machine configuration, I don't have corepack. However, using yarn 4.6.0 I was able to replicate your issue and also fix it in packages/dep/src/index.css:

 @import "tailwindcss" prefix(twp);
+
+@source "./";

The commands I ran:

$ yarn
$ yarn workspace vite-bundle run dev
Before After
Image Image

Does the aforementioned change help you at all @Wroud?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants