documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Generated css package is empty #89

Closed volkanunsal closed 13 years ago

volkanunsal commented 13 years ago

My assets.yml looks like this

https://gist.github.com/672016

When I run jammit --force, the javascript packages are generated fine but css packages are empty. Is this a bug or is there something I'm missing?

jashkenas commented 13 years ago

I can't tell what's going wrong here, just from the assets.yml.

If you want to try and debug it, I'd suggest adding some logs to your Jammit gem, to print out the files it's going through, as it compresses them...

volkanunsal commented 13 years ago

I tried to output the paths inside the packager.rb, but they seemed perfectly normal to me. When I try it from inside compressor.rb#compress_css, the result is empty. Where else should I try?

jashkenas commented 13 years ago

The next place to look would be the method that calls compress_css... Packager#pack_stylesheets...

volkanunsal commented 13 years ago

Yeah...that definitely returns empty. I looked there and then went into what it calls which is compressor.rb#compress_css. It appears that YUI::CssCompressor is where the issue begins.

volkanunsal commented 13 years ago

After this line css variable has a concatenated list of css contents:

css = concatenate_and_tag_assets(paths, variant)

After this one, the css variable is empty:

css = @css_compressor.compress(css) if Jammit.compress_assets

@css_compressor is an instance of the YUI::CssCompressor...so that's the only way out. I have yui compressor listed in the bundled gems. I'm not sure why it's breaking like this.

volkanunsal commented 13 years ago

Did I just close this issue by mistake? Damn.

jashkenas commented 13 years ago

Have you tried it without using Bundler?

volkanunsal commented 13 years ago

When I try to load yui-compressor from irb, I am getting no such file to load error.

ruby-1.8.7-p302 > require "rubygems" => true

ruby-1.8.7-p302 > require "yui-compressor" LoadError: no such file to load -- yui-compressor

ruby-1.8.7-p302 > require "jammit" => true

ruby-1.8.7-p302 > require "yui/compressor" => false

jashkenas commented 13 years ago

Yes, that's require yui/compressor .. also, I'm remembering that the yui-compressor gem doesn't have good handling of errors from Java. Why don't you try using closure-compiler instead, and see if you get the same behavior.

volkanunsal commented 13 years ago

Is there an option I can use in the assets.yaml to do that? It seemed like jammit only lets you specify compressor for the javascript files.

jashkenas commented 13 years ago

Oh, I'm sorry, you're quite right -- the Closure Compiler doesn't do CSS.

How about this -- try running the YUI compressor on your assets manually, against the JAR file, and see if they make it through, or if it's erroring out. If it's erroring, and the yui-compressor gem is failing to throw an exception, I'd suggest opening a ticket here:

https://github.com/sstephenson/ruby-yui-compressor/issues

brainopia commented 13 years ago

Use ruby-yui-compressor 0.9.1 if you have big embedded images in your stylesheets since 0.9.3 and 0.9.4 won't work with it. It's all because in these version used a non-stable version of yui-compressor (2.4.4 while current stable release is 2.4.2).

jashkenas commented 13 years ago

You can also ping sstephenson here, to ask him to put out an updated gem:

https://github.com/sstephenson/ruby-yui-compressor