-
Notifications
You must be signed in to change notification settings - Fork 212
Tailwind intellisense does not work natively with tailwindcss-ruby when using Tailwind V4.X #1224
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
Comments
Hey! What version of the extension are you using? I ask because the extension (and LSP) is designed to load Tailwind CSS APIs through Node (technically Electron when running in VSCode but Node outside). But with the standalone CLI it cannot do that. The way we work around this is by supporting a "fallback" version of Tailwind CSS when it can't find an installed one. I added support for loading a bundled version of v4 in v0.14.3 of the extension so it might fail if you're using an older extension.
I wish this were possible but it's not. The Standalone CLI would itself have to function as a language server to be able to communicate with the extension. I have some ideas on how to make this work but it's not so simple since our LSP has to support multiple versions of Tailwind CSS (going all the way back to v1.x 😱) |
If you're on the latest version, could you provide a reproduction repo I can test with? It's possible we're not handling the fallback version correctly in all cases. |
Here's a reproduction repro: https://github.com/ryancbahan/tailwindcss-intellisense-repro I'm using version 0.14.6. It does fall back to a bundled version of tailwind, but I was hoping to leverage intellisense for our custom config as we have a large project with a lot of updated settings. It sounds like we'd need a node dist of Tailwind to accomplish this given the context you provided (thank you!), and using
I would be interested in helping this along if it's feasible. Thank you for your fast reply! |
Ah, it will still load your stylesheet so your customizations still work. Is there something specific you're seeing that isn't working? You'll see that in the output you get these two lines:
This means that while we couldn't load The biggest thing not supported in the fallback mode right now is importing APIs from the |
I am able to get Tailwind intellisense working with {
"tailwindCSS.experimental.configFile": "app/assets/tailwind/application.css",
} It loads the fallback stylesheet for tailwindcss as you describe. However, if I add the official plugins to @plugin '@tailwindcss/forms';
@plugin '@tailwindcss/aspect-ratio';
@plugin '@tailwindcss/typography'; It works fine in Rails, but I lose my intellisense because it tries to find those plugins in the non-existent node_modules. However, those plugins are bundled inside the CLI tool, so there should also be a fallback for them. Instead my intellisense is broken and I get the following errors in the Tailwind Intellisense log:
|
see #1224 (comment) This adds support for loading these three plugins in v4 **only when using `@plugin`** if we can't find them: - `@tailwindcss/typography` - `@tailwindcss/forms` - `@tailwindcss/aspect-ratio` This coincides with behavior of the Standalone CLI where these are bundled instead of available as an NPM package. I've additionally logs when trying to import one of these plugins inside a JS file. This does not work right now and may take some effort to support because it will at least require the use of Node's experimental loader's API and potentially additional work as well.
@jbigler I've added support for loading these specifically via Loading these packages when using require() or import() inside of a plugin or config is much more difficult. I'm not sure if it's impossible or not but at the very least it'll require the use of some experimental Node APIs (and doing it properly isn't possible until Node v23.6+). |
That's great! I totally understand regarding external plugins. If someone wanted to use those without npm, they'd probably have to do something like in this comment on the tailwindcss-ruby repo. |
I'm upgrading a few apps that use tailwindcss-rails to Tailwind v4. The tailwind rails gem uses tailwindcss-ruby, which vendors the Tailwind executable rather than getting it via npm or node_modules.
This seems to be breaking tailwind intellisense, which appears to always be looking for the tailwind executable in node_modules. When I put a debugger in the extension, I can see output:
Ideally, I'd like to be able to support providing a custom path to the Tailwind executable, rather than needing to add tailwind to my package.json just for the vscode extension. Is there currently a workaround for supporting Tailwind via
tailwindcss-ruby
?The text was updated successfully, but these errors were encountered: