-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Migrate to tailwind v4 #8640
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
Migrate to tailwind v4 #8640
Conversation
c7ca18a
to
187fe37
Compare
Thanks, during the process, can you please check if #8574 will be fixed or if we need to merge that? |
Sure! Thanks for the reminder. Are you aware of other issue / topic like that? |
I will take care of #8574 since I need to address other related styles that aren't complete. I will get to it. Please be patient. |
28d68a6
to
3bfb95e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8640 +/- ##
=======================================
Coverage 99.11% 99.11%
=======================================
Files 141 141
Lines 4073 4073
=======================================
Hits 4037 4037
Misses 36 36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the renamed utilities didn't affect us much so that's great. I didn't realize Flowbite had a v3 update. I'll try to look into the plugin changes and see what we need to bring in. Thank you.
@@ -8,7 +8,7 @@ def install_assets | |||
remove_file "app/assets/stylesheets/active_admin.scss" | |||
remove_file "app/assets/javascripts/active_admin.js" | |||
template "active_admin.css", "app/assets/stylesheets/active_admin.css" | |||
template "tailwind.config.js", "tailwind-active_admin.config.js" | |||
template "tailwind.config.js", "tailwind-active_admin.config.mjs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to do this. What did you run into that you had to make this change? Wouldn't the original version just be treated as an ESM file by the host app as expected? Was there a warning or error by loading this in the new approach from the CSS file now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Hmm that's strange because we do set it in our package.json file.
Line 6 in be13072
"type": "module", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's our package.json, the problem is the test_app. I can't point out who generates that package.json. It could be jsbundling-rails
This reverts commit 3bfb95e.
You are right, it was a nice surprise.
It's relatively new (2025-01-24). @tagliala chose the perfect time to start the conversation about this migration 😄.
Thanks for taking a look into the plugin changes. Please consider that Tailwind V4 made changes to its preflight. |
That was intentional, I did wait for flowbite and css-bundling (which we are using on the CI) support for v4 before, I wouldn't have asked otherwise I'm experimenting with flowbite 3 + tailwind 4 here: https://github.com/diowa/ruby3-rails8-flowbite-render |
@tailwind utilities; | ||
@import "tailwindcss"; | ||
|
||
@config "../../../tailwind-active_admin.config.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The javascript config file is needed by flowbite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the config file is needed to instruct Tailwind to scan our view files (active-admin distributed views).
There is no standard replacement for https://github.com/activeadmin/activeadmin/blob/master/lib/generators/active_admin/assets/templates/tailwind.config.js#L10 yet.
tailwindcss-rails
has an ongoing discussion about engine support here.
I'm playing around with an idea on how to use CSS configuration in 34227e3
@mgrunberg thank you for doing this upgrade. I needed it in order to use vite_rails in my project. So your upgrade will make part of ActiveAdmin vite_rails installation straightforward using default
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
import ViteRails from 'vite-plugin-rails'
export default defineConfig({
plugins: [
tailwindcss(),
ViteRails(),
],
}) I can make a PR to update the docs once your PR merges. |
Superseded by #8709 |
This PR migrates Tailwind v3 to v4. In the process, it upgrades flowbite from 2.3.1 to 3.1.2 (latest).
I made the minimum changes to support v4. I don't pretend to support v3.
Note: I didn't check that the app looks as good as before. Based on @javierjulio comments, that shouldn't be a problem.
Breaking changes
.mjs
extensions. That removes a warning if your project (package.json) is not a type module.Next steps
The goal of this PR is just to use Tailwind v4. I will try to remove js configuration file and plugin usage in another PR