-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
sassc dependency breaks compatibility with tailwindcss-rails #2091
Comments
Please fix this, I have the same problem |
The solution is pretty simple: we need to get rid of all JS/CSS dependencies and just mention how to add them in the README. We must let developers choose the way they handle their assets, whether it's using sassc, webpack or importmap. Maybe we can add some generator |
|
Unfortunately, this may not be simple at all. Before Rails 7, there were two main ways of handling assets: Webpacker and Sprockets. We have tried to make Administrate work with both, but it's difficult work and complex to reproduce issues. Now Rails 7 has arrived with yet another way to do things. We'll have to spend the time to make it work there too, and we would rather that Administrate kept working with previous versions of Rails (at the moment we support Rails 5+). I haven't used Rails 7 yet and I haven't really read much about how the new way to work with assets is. I will have to eventually, but right now I'm a bit short of time so I don't know when I'll get to sit down and figure this out :-/ Fortunately, it doesn't need to be us maintainers who do this work. One of you may be able to volunteer and offer a first stab at the solution. It doesn't need to be a complete PR: an initial prototype could help communicate what exactly needs to happen, and to start testing if there are issues with back compatibility. Any takers? :-) |
@pablobm |
@pablobm Another way to fix this issue is to compile the assets and commit the compiled assets. This would avoid breaking changes. Would you prefer this method? |
@n-studio - I would consider it. If you create a PR so that I can see what it looks like, it can help me understand. |
I've been running into the same issue and the PR by @n-studio seems to fix it, thank you so much! As a hotfix for anyone else running into this, I've added the branch with the fix to the Gemfile like so: gem "administrate", github: "n-studio/administrate", branch: "compile-assets" |
This is a completely valid fix - but it will break if @n-studio deletes that particular branch in the future. And, it's a development branch - not |
What I did for some projects which still depend on Sass was creating my own compressor, which skips the SassC compression if it fails. class SkippingSassCompressor
def compress(string)
options = { syntax: :scss, cache: false, read_cache: false, style: :compressed}
begin
Sprockets::Autoload::SassC::Engine.new(string, options).render
rescue => e
puts "Could not compress '#{string[0..65]}'...: #{e.message}, skipping compression"
string
end
end
end Since the skipped (tailwind) files, are not compressed this way, I just added the "build:css": "tailwindcss -i ./app/assets/stylesheets/home.tailwind.css -o ./app/assets/builds/home.css --minify" I did not test this especially with |
Would this help here? sass/sassc-ruby#220 (comment) / https://github.com/ntkme/sassc-embedded-shim-ruby |
I ended up going down the same route as @tkoenig. It seems to work well for the time being 👍 |
dependency bugfix thoughtbot/administrate#2091
We are currently using the fork by @n-studio, but we would love to run the official version with the new features. Is anyone working on this still? We are using the new Rails 7 defaults (cssbundling-rails & jsbundling-rails). |
|
Moving to dartsass-rails will fix this issue, i currently got it working with dartsass, i had to generate the administrate gem stylesheets in my project |
i just updated the branch, now you dont need to generate the assets in your project |
seems that Administrate depends on SassC compression which does not work with TailwindCSS and so implemented the fix from thoughtbot/administrate#2091 (comment) This seemed not to affect development and only showed up in tests. Presumably this would affect production.
Neither of the forks above worked for me (because I think administrate has pushed new commits after those forks were made). So I created a new up-to-date fork here: https://github.com/materialsnow/administrate You can run It works for me as of this posting. I'm using Rails 7.0.4. Best of luck! |
Assets compilation was failing because tailwind css is trying to be compressed by sassc. Read: thoughtbot/administrate#2091 I have updated test and production enviroments and added a test that checks that no errors ocurs on the precompile task and that production config is matching tests in this specific scenario
I also tried various forks and solutions mentioned on this issue page. Nothing worked. I created a fork myself https://github.com/oroth8/administrate and it works perfectly with my rails 7 tailwind configured app. |
I would love it if there was official support for this. |
Actually, it looks like we managed to continue to use administrate, even with its dependency on the old sassc-rails, while the rest of our app changes to cssbundling-rails with Dart Sass (for our legacy views) and Tailwind (for new views). The key for us was to ensure |
Thank you all for your solutions to this, it's been a headache! You solution @sedubois worked for me, thank you for sharing it. I just dropped |
Thank you all for your solutions to this. Your solution @kaka-ruto @sedubois Thank You. I just dropped Rails.application.config.assets.css_compressor = nil in config/initializers/assets.rb and it worked. |
I'm going to close this we've just merged in #2397, which will mean that in future release we'll be bundling assets in the Administrate Gem and so we've been able to drop any dependencies on assets from those using the gem. I'm expecting this will mean Tailwind will work fine now, regardless of how you go about bundling the assets in your applications. I'm going to start releasing some pre-release versions of the gem in the coming days, as I'm sure I'm about to break stuff for people, and so we can get feedback and make sure there's nice migration help sorted out. |
I'm trying to use tailwind-rails v2.0.2 and importmaps.
I'm getting a
SassC::SyntaxError
when I runrake assets:precompile
. Based on my debugging, it's becausetailwind-rails
is incompatible with thesassc-rails
gem that administrate requires as a dependency:Rails 7.0
Administrate 0.16.0
The text was updated successfully, but these errors were encountered: