Sha256: bd50db18cb0363c8631cc6b5935bd3ec80e7c9ad051c8d1602d811798ded7f34

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

# encoding: utf-8

require 'sprockets'
module ClassyAssets
  class Sprockets
    attr_accessor :asset_root, :environment
    def initialize
      @config = ClassyAssets.config
      @asset_root = @config.asset_root
      @environment = new_sprockets_environment
    end

    private

    def new_sprockets_environment
      sprockets_environment = ::Sprockets::Environment.new(asset_root) do
        @version = @config.asset_version
      end
      
      @config.asset_paths.each do |asset_path|
        sprockets_environment.append_path asset_path
      end

      if @config.asset_compress
        sprockets_environment.css_compressor = @config.css_compressor
        sprockets_environment.js_compressor  = @config.js_compressor
      end

      sprockets_environment.context_class.class_eval do
        def asset_path(path, options = {})
          ClassyAssets.asset_url_for(path)
        end
      end
      sprockets_environment
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
classy_assets-0.14.5 lib/classy_assets/sprockets.rb