lib/middleman-webp/extension.rb in middleman-webp-0.2.7 vs lib/middleman-webp/extension.rb in middleman-webp-0.3.0

- old
+ new

@@ -11,16 +11,24 @@ 'keep the original filename and extension and append .webp (image.png => image.png.webp)') option(:ignore, [], 'Ignores files with matching paths') option(:verbose, false, 'Display all external command which are executed '\ 'to help debugging.') option(:allow_skip, true, 'Skip saving .webp files which are larger than their source') + option(:run_before_build, false, 'Run before build and save .webp files in source dir') def initialize(app, options_hash = {}, &block) super @app = app end + def before_build(builder) + return unless options[:run_before_build] + return unless dependencies_installed?(builder) + Middleman::WebP::Converter.new(@app, options, builder).convert + end + def after_build(builder) + return if options[:run_before_build] return unless dependencies_installed?(builder) Middleman::WebP::Converter.new(@app, options, builder).convert end # Internal: Check that cwebp and gif2webp commandline tools are available.