Skip to content

[Admin] Fix tailwindcss-rails Version to v3 for Solidus Admin Compatibility#6135

Merged
tvdeyen merged 1 commit intosolidusio:mainfrom
swamp09:fix_tailwindcss_rails_v3_to_install_tailwindcss
Feb 19, 2025
Merged

[Admin] Fix tailwindcss-rails Version to v3 for Solidus Admin Compatibility#6135
tvdeyen merged 1 commit intosolidusio:mainfrom
swamp09:fix_tailwindcss_rails_v3_to_install_tailwindcss

Conversation

@swamp09
Copy link
Copy Markdown
Contributor

@swamp09 swamp09 commented Feb 19, 2025

Background

Currently, running bin/rails solidus_admin:tailwindcss:install installs the latest v4 of tailwindcss-rails. This causes compatibility issues because Solidus Admin expects the Tailwind CSS v3 configuration.

Tailwind CSS v4 introduces CSS First Configuration, which alters the structure and handling of the tailwind.config.js file. Using v4 results in a configuration where tailwind.config.js does not function properly. Reference: https://tailwindcss.com/blog/tailwindcss-v4#css-first-configuration

While ideally, Solidus Admin should be updated to work with Tailwind CSS v4 and later, we have restricted it to v3 for now to ensure correct functionality. Additionally, the maintainers of tailwindcss-rails do not recommend upgrading to v4 at this time (see: https://github.com/rails/tailwindcss-rails?tab=readme-ov-file#you-dont-_have_-to-upgrade).

Solution

Modified the installation command in install_tailwindcss.rb to explicitly install v3:

unless bundle_command "show tailwindcss-rails"
  bundle_command "add tailwindcss-rails --version '~>3.0'"
end

This change ensures that running bin/rails solidus_admin:tailwindcss:install installs Tailwind CSS v3, which is compatible with Solidus Admin's current configuration.

If there is anything else that should be added or any improvements that can be made, please let me know.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

…bility

## Background

Currently, running `bin/rails solidus_admin:tailwindcss:install` installs the latest v4 of `tailwindcss-rails`. This causes compatibility issues because Solidus Admin expects the Tailwind CSS v3 configuration.

Tailwind CSS v4 introduces CSS First Configuration, which alters the structure and handling of the `tailwind.config.js` file. Using v4 results in a configuration where `tailwind.config.js` does not function properly. Reference: https://tailwindcss.com/blog/tailwindcss-v4#css-first-configuration

While ideally, Solidus Admin should be updated to work with Tailwind CSS v4 and later, we have restricted it to v3 for now to ensure correct functionality. Additionally, the maintainers of `tailwindcss-rails` do not recommend upgrading to v4 at this time (see: https://github.com/rails/tailwindcss-rails?tab=readme-ov-file#you-dont-_have_-to-upgrade).

## Solution

Modified the installation command in `install_tailwindcss.rb` to explicitly install v3:

```ruby
unless bundle_command "show tailwindcss-rails"
  bundle_command "add tailwindcss-rails --version '~>3.0'"
end
```

This change ensures that running bin/rails solidus_admin:tailwindcss:install installs Tailwind CSS v3, which is compatible with Solidus Admin's current configuration.

If there is anything else that should be added or any improvements that can be made, please let me know.
@swamp09 swamp09 requested a review from a team as a code owner February 19, 2025 03:50
Copy link
Copy Markdown
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Thanks. 🙏

Note: We really need to think about compiling the stylesheets and js files into the gem and simply serve it from whatever tool the app uses (sprockets or propshaft)

For now this fixes installation issues.

@tvdeyen tvdeyen added this to the 4.5 milestone Feb 19, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.81%. Comparing base (08207da) to head (50db6ad).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
admin/lib/solidus_admin/install_tailwindcss.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6135   +/-   ##
=======================================
  Coverage   88.81%   88.81%           
=======================================
  Files         835      835           
  Lines       18146    18146           
=======================================
  Hits        16116    16116           
  Misses       2030     2030           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tvdeyen tvdeyen merged commit bae3c67 into solidusio:main Feb 19, 2025
@swamp09 swamp09 deleted the fix_tailwindcss_rails_v3_to_install_tailwindcss branch February 19, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants