Closed marvindanig closed 9 years ago
Are you passing any options to htmlcompressor? My first impression is that you specified an unsupported object as css compressor (any object that has a compress method is supported)
I've these options for the htmlcompressor:
config.middleware.use HtmlCompressor::Rack,
compress_css: true,
compress_javascript: true,
css_compressor: Sass,
enabled: true,
javascript_compressor: uglifier,
preserve_line_breaks: false,
remove_comments: true,
remove_form_attributes: false,
remove_http_protocol: false,
remove_https_protocol: false,
remove_input_attributes: true,
remove_intertag_spaces: false,
remove_javascript_protocol: true,
remove_link_attributes: true,
remove_multi_spaces: true,
remove_quotes: true,
remove_script_attributes: true,
remove_style_attributes: true,
simple_boolean_attributes: true,
simple_doctype: false
This has been working normal all this while, until today. And logs didn't show this error before. Which object do you suspect are unsupported and people could easily include?
Here's the problem: Sass is not supported as a css compressor.
Not even sure it can be used as a compressor.
You could set it to :yui
(requires gem yui-compressor
) or use something else like cosmic (but may need some additional wrapping)
See here for more infos https://github.com/paolochiodi/htmlcompressor#css-and-javascript-compression
Anyway, chances are that you don't even need css compression in your html files. Do you have lot of <style>
tags in them?
Just one style tag overall or maximum two on a few specific pages. Interesting that the error never popped up on my actual production server so far. What is Cosmic? Sounds like an interesting name.
Hmm, so the compression of CSS need not be specified 'coz rails is doing it anyway. Let me see if it can be done away with. Thanks Paolo :+1:
The css compression options is to enable compression of css inside <style>
directly in your html pages.
External stylesheets linked with the <link>
are already handled by Rails and Sass.
You probably never seen it in production because you don't have a <style>
tag in your pages?
If you need it, check the yui-compressor
gem: it will require java to be installed but it's the best option.
Cosmic = ccsmin, damn corrector...
:+1:
I'm getting the following error only on production mode:
Completed 500 Internal Server Error in 15ms (Views: 0.6ms | ActiveRecord: 2.3ms) F, [2015-02-02T10:21:13.342194 #17722] FATAL -- : NoMethodError (undefined method
compress' for Sass:Module): htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:555:in
compress_css_styles' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:495:inblock in process_style_blocks' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:494:in
map!' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:494:inprocess_style_blocks' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:476:in
process_preserved_blocks' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:202:incompress' htmlcompressor (0.1.2) lib/htmlcompressor/rack.rb:45:in
call'Didn't see this been reported before, but is no one else seeing it?