Method: Propshaft::Compressor.compress_assets

Defined in:
lib/propshaft/compressor.rb

.compress_assets(processor) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/propshaft/compressor.rb', line 17

def self.compress_assets(processor)
  processor.load_path.assets.each do |asset|
    in_path = processor.output_path.join(asset.digested_path).to_s
    next if SKIP_EXTS.any?{|ext| in_path.ends_with? ".#{ext}" }

    FORMATS.each do |ext, (klass, level)|
      out_path = processor.output_path.join(asset.digested_path.to_s+ext)
      unless out_path.exist?
        Propshaft.logger.info "Writing #{asset.digested_path}#{ext}"
        klass.compress from: in_path, to: out_path, level: level
      end
    end
  end
end