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

Add config to install ruby_ui with import maps and tailwind 4 #232

Merged
merged 4 commits into from
Mar 25, 2025

Conversation

karinevieira
Copy link
Contributor

Following Seth's initiative, I'm adding a CSS template to enable the installation of ruby_ui in Rails applications that use import maps and the tailwind-css gem with Tailwind 4.

@karinevieira karinevieira force-pushed the karinevieira/upgrade_tailwind_4 branch from 94f2225 to bd5eb12 Compare March 22, 2025 16:19
@karinevieira karinevieira changed the title Add css template to install ruby_ui with import maps and tailwind 4 Add config to install ruby_ui with import maps and tailwind 4 Mar 22, 2025
@karinevieira karinevieira force-pushed the karinevieira/upgrade_tailwind_4 branch from bd5eb12 to da0070d Compare March 22, 2025 19:35
@karinevieira karinevieira force-pushed the karinevieira/upgrade_tailwind_4 branch from d9ba15e to 26995d3 Compare March 22, 2025 22:33
Comment on lines +4 to +5
@plugin "@tailwindcss/forms";
@plugin "@tailwindcss/typography";
Copy link
Contributor Author

@karinevieira karinevieira Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tailwind 4 brought container query support into core so we don't need the @tailwindcss/container-queries plugin anymore.

Copy link
Contributor

@sdhull sdhull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I think there's one errant line but then it will probably be good to go! I tried this locally since I'm working on spinning up a new project with latest & greatest everything and this has helped me immensely! I removed that one line and (while I'm still just barely getting started), at least rails tailwindcss:watch works now!

@@ -0,0 +1,153 @@
@import "tailwindcss";
@import "../../../vendor/javascript/tw-animate-css.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line? I think something from your project might have snuck in here...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe this is somehow related to the tailwind animate plugin? But when I ran importmap pin tailwindcss-animate it did not add that file to my vendor dir:

importmap pin tailwindcss-animate
Pinning "tailwindcss-animate" to vendor/javascript/tailwindcss-animate.js via download from https://ga.jspm.io/npm:[email protected]/index.js
Pinning "tailwindcss/plugin" to vendor/javascript/tailwindcss/plugin.js via download from https://ga.jspm.io/npm:[email protected]/dist/plugin.js

Weirdly the output seems to indicate that it saves the tailwind plugin file at vendor/javascript/tailwindcss/plugin.js but instead it added vendor/javascript/tailwindcss--plugin.js

Copy link
Contributor Author

@karinevieira karinevieira Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line? I think something from your project might have snuck in here...?

That's right @sdhull, exactly!

The tailwindcss-animate library does not support Tailwind 4, so as an alternative, I am using tw-animate-css. However, when installing it with importmaps, this file is added to my project: vendor/javascript/tw-animate-css.js.

To successfully start the application using bin/dev, I had to modify the path to make it work properly. Otherwise, I get the following error:

Error: Can't resolve 'tw-animate-css' in 'my_project_path/app/assets/tailwind'

@stephannv
Copy link
Contributor

Thanks 🚀

@stephannv stephannv merged commit 1c755e4 into ruby-ui:main Mar 25, 2025
2 checks passed
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 this pull request may close these issues.

3 participants