class Middleman::Rack::MinifyJavascript
def call(env)
def call(env) status, headers, response = @app.call(env) if env["PATH_INFO"].match(/\.js$/) compressor = ::Uglifier.new if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile) uncompressed_source = File.read(response.path) else uncompressed_source = response.join end minified = compressor.compile(uncompressed_source) headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s response = [minified] end [status, headers, response] end