Class: EasyHtmlGenerator::Generator::Minimize::Images

Inherits:
Compile::Base show all
Defined in:
lib/easy_html_generator/generator/minimize/images.rb

Overview

this generator minifies image files from src folder and copies them to the dist folder

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Compile::Base

#do_file, #generate!, #input_to_output_file, #walk_files, #watch_files

Methods inherited from Base

#enabled?, #file_changed?, #generate, #generate!, #initialize, #log, #log_running, #repetitive?, #store_file_hash, #tasks

Constructor Details

This class inherits a constructor from EasyHtmlGenerator::Generator::Base

Instance Method Details

#do_input!(_input, input_file, output_file, config) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/easy_html_generator/generator/minimize/images.rb', line 10

def do_input!(_input, input_file, output_file, config)
  FileUtils.copy(input_file, output_file) unless input_file == output_file

  Piet.optimize(output_file, config.options)

  nil
rescue StandardError
  log '-> you have to install "optipng" and "jpegoptim"'.red
end