Skip to content
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

[v4] Resolve @import or @source from vite.resolve.alias #15159

Closed
TiBianMod opened this issue Nov 24, 2024 · 2 comments · Fixed by #15173
Closed

[v4] Resolve @import or @source from vite.resolve.alias #15159

TiBianMod opened this issue Nov 24, 2024 · 2 comments · Fixed by #15173

Comments

@TiBianMod
Copy link

What version of Tailwind CSS are you using?

tailwindcss: v4.0.0-beta.2
@tailwindcss/vite: v4.0.0-beta.2
@tailwindcss/postcss: v4.0.0-beta.2

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

vite: v5.4.11

What browser are you using?

Chrome, Safari, etc

What operating system are you using?

macOS

Reproduction URL

https://github.com/TiBianMod/vite-tailwindcss

Reproduction contains 3 Branches

  • main: without tailwindcss WORKING
  • @tailwindcss/postcss: WORKING
  • @tailwindcss/vite: NOT WORKING - Throws

Describe your issue

  VITE v5.4.11  ready in 403 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

7:51:44 PM [vite] Internal server error: Can't resolve '#resolveThisCss' in '/Users/user/Code/vite-tailwindcss/src'
  Plugin: @tailwindcss/vite:generate:serve
@philipp-spiess
Copy link
Member

Hey! Agree this is an issue right now. We're already tracking this as #15047 so I'm going to merge the two issues and close this one.

@philipp-spiess
Copy link
Member

Going to reopen this one as #15047 does not repro for me so the fix will not work for the other issue. This issue is something we can fix, though. Looking into it 👀

adamwathan added a commit that referenced this issue Nov 27, 2024
Closes #15159

This PR extends the `@tailwindcss/node` packages to be able to overwrite
the CSS and JS resolvers. This is necessary as some bundlers, in
particular Vite, have a custom module resolution system that can be
individually configured. E.g. in Vite it is possible to add custom
[resolver
configs](https://vite.dev/config/shared-options.html#resolve-conditions)
that is expected to be taken into account.

With the new `customCssResolver` and `customJsResolver` option, we're
able to use the Vite resolvers which take these configs into account.

## Test Plan

Tested in the playground by configuring [resolver
conditions](https://vite.dev/config/shared-options.html#resolve-conditions)
(with Vite 5.4 and Vite 6 beta). An integration test was added for both
the JS and CSS resolvers to ensure it keeps working as expected.

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
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

Successfully merging a pull request may close this issue.

2 participants