Sha256: 7ffef867aedccc26b346318f00b1037c498f58d847a36c4d7fbab39c4438bfe9
Contents?: true
Size: 797 Bytes
Versions: 2
Compression:
Stored size: 797 Bytes
Contents
begin require "yui/compressor" rescue LoadError puts "YUI-Compressor not available. Install it with: gem install yui-compressor" end class Middleman::Rack::MinifyJavascript def initialize(app, options={}) @app = app end def call(env) if Middleman::Base.enabled?(:minify_javascript) && env["DOWNSTREAM"] && env["PATH_INFO"].match(/\.js$/) compressor = ::YUI::JavaScriptCompressor.new(:munge => true) source = env["DOWNSTREAM"][2].is_a?(::Rack::File) ? File.read(env["DOWNSTREAM"][2].path) : env["DOWNSTREAM"][2] env["DOWNSTREAM"][2] = compressor.compress(source) env["DOWNSTREAM"][1]["Content-Length"] = ::Rack::Utils.bytesize(env["DOWNSTREAM"][2]).to_s end @app.call(env) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
middleman-0.13.2.pre | lib/middleman/rack/minify_javascript.rb |
middleman-0.13.1 | lib/middleman/rack/minify_javascript.rb |