zweilove / css_splitter

Gem for splitting up stylesheets that go beyond the IE limit of 4095 selectors, for Rails 3.1+ apps using the Asset Pipeline.
MIT License
160 stars 47 forks source link

split2 css file duplicates original (followed GOTCHAS but still) #21

Closed samsonkhisty closed 11 years ago

samsonkhisty commented 11 years ago

Hi Guys, I've been at it for 2 days now. Has anyone else encountered this issue?

Followed the readme carefully but unfortunately the split2 file is an exact copy.

--- APPLICATION.CSS---  
 *= require theme/style.css.scss.erb
 *= require font-awesome
 */
.foo { }
--- NOTE: style.css.erb has @import which imports several other css including bootstrap & bootstrap-responsive

--- APPLICATION_SPLIT2.CSS.SPLIT2 --- //= include 'application.css'

--- PRODUCTION.RB --- config.assets.precompile += %w(application.css application_split2.css)

--- GEM FILE --- group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'turbo-sprockets-rails3' gem 'uglifier', '>= 1.0.3' gem 'yui-compressor' #compress css end

Other notes: I have built a rake task to also check the selectors in my application.css using the count_selectors method and count is around 4909.

Any help is appreciated. Thanks. Sam

UPDATE: I built up on the rake task and included other methods and finally passed the precompiled application.css and the output of the "extract_part" method did extract around 4057 selectors.

Not sure what else am I missing here.

jhilden commented 11 years ago

@samsonkhisty would it be possible to get a copy of your stylesheets to see what the problem could be?

I didn't quite understand what you did in your "UPDATE" and what it is supposed to mean. Further information would be appreciated.

samsonkhisty commented 11 years ago

@jhilden Basically for now to get it to work, I built my own rake task to run after precompilation - I pulled out the core methods of the gem (split_string, extract_part, etc) to manually split my CSS as a post step. In other words, I can manually split my CSS correctly with the core library, but it seems when this is part of the gem & sprockets pipeline, the file is not split but instead duplicated.

jhilden commented 11 years ago

That's weird.

It works with the test stylesheets here: https://github.com/zweilove/css_splitter/tree/master/test/dummy/app/assets So there must be something different about your stylesheet. I would really love to create a test case that reproduces the issue you are seeing.

jhilden commented 11 years ago

@samsonkhisty can you provide any addition details that would allow me to debug the issue? otherwise I'm closing this issue.

prusswan commented 10 years ago

encountered a similar problem, except that our application.css used to be like:

/*
 *= require_self
 *= require vendor
 *= require bootstrap-select
 */

/* custom styles below */

with the custom styles moved to main.css, and require_self replaced with require main

Burkazoid commented 10 years ago

I'm experiencing this exact issue as well. I noticed that @samsonkhisty also had .foo { } in their sheet, which I too had to add due to issue #12. I wonder if this is the root of the problem? That would align with @prusswan's experience as well since they had custom styles on application.css as well.

Burkazoid commented 10 years ago

Here are my exact files:

application.css:

/*
 *= require_tree ./vendor/global
 *= require_tree ./global
 *= require jquery.ui.core
 *= require jquery.ui.theme
 *= require jquery.ui.resizable
 *= require jquery.ui.selectable
 *= require jquery.ui.datepicker
 *= require jquery.ui.slider
 *= require jquery.ui.tabs
 *= require jquery.fileupload-ui
 *= require jquery.timepicker.css
 *= require select2
*/

application_split2.css.split2:

/*
 *= include 'application.css' 
 */

.foo {}
samsonkhisty commented 10 years ago

@jamesburke-examtime, I still haven't figured it out. Eventually, I used part of the code logic in my own rake task that splits it after pre-compilation. Works for now.

What does your gem file look like?

Burkazoid commented 10 years ago

@samsonkhisty It's pretty substantial!

We ended up just splitting our application.css ourselves and using IE conditionals to load the split versions instead (essential what the gem is doing); otherwise, if not IE, then load the application.css (which includes all the split versions).

samsonkhisty commented 10 years ago

Yes, we did the same thing too. I'm suspecting something to do with some gem, I may be wrong.

Given the time, I wanted to confirm my doubts by removing gems one by one and isolating it. Never got around to it. Lazy.

Umofomia commented 10 years ago

FYI to anyone still following this: this is now being tracked in #29, and I'll be looking into creating a fix soon.