split2 file is always empty
marc-villanueva opened this issue · 9 comments
We recently updated our application from the 0.2.0 release of the gem to the current master. Now our application_split2.css file is always empty even though it is well past the 4095 selector count. After a bit of debugging, this clause in splitter.rb:42 always evaluates to true for every rule in the file. Therefore, nothing is ever written to the split file.
if rule =~ /^\s*}$/
current_media = nil
# skip the line if the close bracket is the first rule for the new file
next if first_hit
end
I wrote a simple test to verify:
def test_split_string_failure
second_part = CssSplitter::Splitter.split_string(File.read('test/dummy/app/assets/stylesheets/test_stylesheet_with_media_queries.css'), 2)
refute_empty second_part
end
Is anyone else seeing this issue?
@marc-villanueva can you test again with the current version from master? I think #35 should have fixed your issue.
I just tried master on our project and had the same problem.
Thanks for the feedback @aaronjensen Could you provide additional details about your setup/files? Did you follow the new instructions in the README (e.g. use require
instead of include
)? How is your original stylesheet composed?
Yep, I used require
and dropped the .split2
suffix. I'm not sure what you mean by composure, but it uses @import
statements. The current gem release works fine.
I also nuked public/assets and tmp/cache/assets
Yes, with composure I was referring to Sass @import
vs. sprockets etc.
I just did a test run with this file (https://github.com/zweilove/css_splitter/blob/master/test/dummy/app/assets/stylesheets/combined.css.scss) using @import
instead of require
and it worked well.
Any more details you can provide?
hmm, not sure. Rails 4.0.4, sass 3.2.19, sprockets 2.11.0. I'm also using sprockets-derailleur.
I lack the intimate knowledge of how sprockets works, but I would think it might be worth trying it without sprockets-derailleur
@jhilden same result w/o it. I see the same behavior that @marc-villanueva sees, splitter.rb:42 is always true. Every rule ends in a curly brace, so i'm not entirely sure what that line of code is meant to do.