Sha256: f9e703aceffa64838406bbd0065aeabf5d2af447b5338fef3734d12da70de761

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

require 'sprockets/exporters/base'
require 'webp-ffi'

module Sprockets
  module Exporters
    # Generates a `.webp` file using the webp-ffi
    class WebpExporter < Exporters::Base
      def setup
        @webp_target = "#{ target }.webp"
      end

      def skip?(logger)
        if ::File.exist?(@webp_target)
          logger.debug "Skipping #{ @webp_target }, already exists"
          true
        else
          logger.info "Writing #{ @webp_target }"
          false
        end
      end

      def call
        ::WebP.encode(target, @webp_target, Sprockets::WebP.encode_options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprockets-webp-exporter-0.1.0.rc1 lib/sprockets/exporters/webp_exporter.rb