Method: R2::Swapper#minimize
- Defined in:
- lib/r2.rb
#minimize(css) ⇒ Object
Minimize the provided CSS by removing comments, and extra specs
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/r2.rb', line 116 def minimize(css) return '' unless css css.gsub(/\/\*\s*no-r2\s*\*\//, SKIP_TOKEN). # special skip comment gsub(/\/\*[\s\S]+?\*\//, ''). # comments gsub(/[\n\r]+/, ' '). # line breaks and carriage returns gsub(/\s*([:;,\{\}])\s*/, '\1'). # space between selectors, declarations, properties and values gsub(/\s+/, ' '). # replace multiple spaces with single spaces gsub(/(\A\s+|\s+\z)/, '') # leading or trailing spaces end |