-
Notifications
You must be signed in to change notification settings - Fork 93
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
Update for Tailwind CSS v4 #164
base: main
Are you sure you want to change the base?
Conversation
Tailwind CSS v4 comes with new configurations and build scripts. This updates the installer for Tailwind to include those changes.
lib/install/tailwind/install.rb
Outdated
|
||
say "Add build:css script" | ||
add_package_json_script "build:css", | ||
"tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify" | ||
"npx @tailwindcss/cli -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify" |
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.
It would be interesting to add to lib/install/helpers.rb something to support bun in order to use bunx/npx depending of what tools the user wanted to use.
def bundler_x_cmd
using_bun? ? "bunx" : "npx"
end
Then you could do:
"#{bundler_x_cmd} @tailwindcss/cli -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
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.
Sounds good to me. I just added support in my latest commit #a0df0b7
@@ -2,6 +2,6 @@ | |||
"name": "app", | |||
"private": "true", | |||
"scripts": { | |||
"build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css" | |||
"build:css": "npx @tailwindcss/cli -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css" |
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.
Is it really necessary to run npx
if you add @tailwindcss/cli
as a depedency?
Also, would this also be a place to use bunx
if using bun?
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.
In my testing, something like npx
or bunx
is necessary to run the new @tailwindcss/cli
package. The Tailwind docs have this, so I was going off that.
To be honest, I'm not sure this package.json
file is necessary.
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.
It is necessary because cssbundling-rails and jsbundling-rails are enhancing some rake tasks like precompile:assets to call this build and build:css task present in the package.json
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.
@navidemad I mean the package.json
file inside the lib/install/tailwind
directory. I see no reference to it in rake tasks or elsewhere. I could be mistaken, of course.
Is there anything i can help with to advance with this PR? Is there anything missing? For me, all the changes are working. Hope to see |
This is a pull request based on #163
Tailwind CSS v4 has new configurations that are simpler than v3 and prior.
Summary of changes:
tailwind.config.js
file@tailwind
directives for normal@import "tailwindcss"
support.npx
and@tailwindcss/cli
to build cssLet me know if you see any red flags!