-
Notifications
You must be signed in to change notification settings - Fork 173
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
tailwindcss-rails raising SassC::SyntaxError #82
Comments
Also getting this error in when running integration & controller test found this stack overflow post which lead me to use this in my gemfile gem "tailwindcss-rails", |
I can confirm, same thing is happening with my setup. |
@dixpac If you want to dive into this one. We have to find a way such that Sassc is not being applied to the TW output. |
Alright. I'll give my best 😊 |
Same issue. Trying the forked gem for now. Subscribed 👍 |
Is there any news about this issue? thanks |
Before my Rails App was running on version 6.1.4 . I just started a fresh app on Rails7.0.0Alpha2 and I am no longer encountering the issue I described in an earlier post. |
This is not a problem on Rails 7 out of the box because we no longer default to having Sass turned on there. There's still a compatibility issue if you turn Sass on, because SassC doesn't understand the modern CSS syntax used by TW. |
At the point of running the compression we don't really need sass specifically. Any compressor should be fine, right? The Rails Guides still talk about |
Added a note to the README about this compatibility issue. |
I ran into this recently (outside of using
require "open3"
class CssoCompressor
def self.call(input)
puts "[CssoCompressor] Compressing…"
# Copy the contents of the CSS file to a temp file
temp_file = Tempfile.new([input[:name], ".css"])
temp_file.open
temp_file.write(input[:data])
temp_file.flush
# Run the compressor and capture the output
css, err, status = Open3.capture3("npx", "csso", temp_file.path)
{data: css}
end
end
Rails.application.config.assets.configure do |env|
env.register_compressor "text/css", :csso, CssoCompressor
end A Sprockets compressor is just a class with a
config.assets.css_compressor = :csso /cc @MSchmidt |
@domchristie, that worked perfectly for me! |
@domchristie You saved me! Your solution works perfect. |
While monkeypatching isn't advisable, you may find this useful if you're in a transitional phase where you need tailwind & sass at the same time. module SassCompressorMonkeypatch
def call_processor(processor, input)
super
rescue SassC::SyntaxError => e
raise unless processor == Sprockets::SassCompressor
puts "Warning: Could not compress #{input[:filename]} with Sprockets::SassCompressor. Returning uncompressed result."
metadata = (input[:metadata] || {}).dup
metadata[:data] = input[:data]
metadata
end
end
Sprockets::Base.prepend(SassCompressorMonkeypatch) This simply rescues |
I am using
gem 'tailwindcss-rails'
Layout:
Production:
config.assets.css_compressor = :purger
In circle ci it's raising a following error
The text was updated successfully, but these errors were encountered: