-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Vite: Use Vite resolvers for CSS and JS files #15173
Conversation
Nice to see you working on this PR @philipp-spiess. Thank you 🙏 if you need to test create new file @source "../src"; add on /* after the imports */
@source "#resolveThisSource"; add "#resolveThisSource": fileURLToPath(new URL('./src/resolve_this_source.css', import.meta.url)) |
@TiBianMod What's your use case for using these aliases for |
70652fc
to
9860535
Compare
9860535
to
44d21ea
Compare
@philipp-spiess |
This seems related to a problem I'm having with the v4 beta.2 in a Rush/pnpm monorepo. The issue I'm having manifests as a recursion issue:
This happens with the Vite plugin and the postcss plugin. I'd be happy to test a build and file a separate issue if it ends up not being related. Thank you for your hard work on this, I'm excited about getting started with v4 |
@sdalonzo If this happens with postcss too, I don't think this is related to this issue I'm afraid. Mind opening up a new issue with a repro case? One thing from the top of my head is that it seems omit the file extension for the import as it says |
@philipp-spiess I'm working on a minimal repro since I need it in order to open the issue - it'll just take a little while because i have to recreate the monorepo conditions first. In the meantime, I'm not sure what you meant by adding the .css extension. My css file has |
@sdalonzo Oh interesting! We'll need to figure out where that import is coming from, because the internal |
@philipp-spiess even more frustratingly, my repro passed the build and just has some issues in storybook that are probably solvable. I'm working on adding more until I can reproduce. |
excited for the next release 🎉 |
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 that is expected to be taken into account.With the new
customCssResolver
andcustomJsResolver
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 (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.