6

I upgraded the tailwindcss-rails gem and got this error when compiling assets for production:

bundle exec rails assets:precompile
rails aborted!
SassC::SyntaxError: Error: unterminated attribute selector for type
        on line 1009:16 of stdin
>> .prose ol[type="A" s] {

   ---------------^
/home/circleci/project/vendor/bundle/ruby/3.0.0/bundler/gems/sassc-ruby-4fce2b635ca5/lib/sassc/engine.rb:50:in `render'
/home/circleci/project/vendor/bundle/ruby/3.0.0/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb:29:in `call'
/home/circleci/project/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sass_compressor.rb:30:in `call'

2 Answers 2

4

The issue is that this new syntax for CSS rules is not supported by libsass / sassc.

So I ended up forking tailwindcss-rails and remove the extras.

It's on GitHub: https://github.com/dorianmariefr/tailwindcss-rails/tree/minimal

And you can use it like this in your Gemfile:

gem "tailwindcss-rails",
    github: "dorianmariefr/tailwindcss-rails",
    branch: "minimal"
Sign up to request clarification or add additional context in comments.

5 Comments

I had a similar issue where I couldn't use @tailwind/typography, what I ended up doing was changing the file type of the file i was importing tailwind into from .scss to .css. Although that might not be suitable for your usecase.
Did you consider switching to dart-sass instead? libsass is no longer under development and will become less and less compatible as front end packages start using stuff like the new @use module system.
@max I would love to switch to dart-sass, just not sure how to do it
I missed that you were still using sprockets which might make the transition more challenging.
looks like in might be fixed in Rails 7 github.com/rails/rails/pull/43110
2

I kept having the SassC::SyntaxError. Adding the following line in production.rb resolved the issue:

config.assets.css_compressor = nil

It will prevent sassc-rails from setting sass as the compressor.

I found the answer here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.