Boti
Boti

Reputation: 3445

I need a css minifier in ruby

I am looking for a css minifier that I could use in rails apps (not gziper) which doesn't need a command line YUI compressor instalation. I am working on a content mangament software where the css is pasted into a textarea and then I want to minify then gzip and send it to amazon. So those solutions are not OK which use some command line preprocessing... Any ideas?

Online minifier services are also welcome.

Upvotes: 11

Views: 4408

Answers (4)

Neyaz Khan
Neyaz Khan

Reputation: 1

1.Install Ruby and open 2.install gem by entering ' gem install saas ' press enter. 3.type sass -scss -t compressed 'source file' then 'destinationfile'.

ex- sass -scss -t compressed sass/_theme.scss css/theme.css

Upvotes: 0

Boti
Boti

Reputation: 3445

I think I have found my gem:

'ruby-yui-compressor'

All I need to do:

gem "yui-compressor", "~> 0.9.6", :require => "yui/compressor"
....
compressor = YUI::CssCompressor.new
compressor.compress 'body {line-height: 1}            \ntable {border-collapse: collapse;    border-spacing: 0}'

=> "body{line-height:1}\\ntable{border-collapse:collapse;border-spacing:0}" 

Upvotes: 4

Luchs
Luchs

Reputation: 1168

You could also try SASS with :syntax => :scss, :style => :compressed.

Upvotes: 12

Kudu
Kudu

Reputation: 6888

How about Juicer?

Upvotes: 2

Related Questions