commit
1727251be5
1 changed files with 9 additions and 4 deletions
|
@ -18,9 +18,14 @@ module Middleman
|
||||||
if env["PATH_INFO"].match(/\.js$/)
|
if env["PATH_INFO"].match(/\.js$/)
|
||||||
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
||||||
|
|
||||||
uncompressed_source = response.is_a?(::Rack::File) ? File.read(response.path) : response
|
if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile)
|
||||||
response = compressor.compress(uncompressed_source)
|
uncompressed_source = File.read(response.path)
|
||||||
headers["Content-Length"] = ::Rack::Utils.bytesize(response).to_s
|
else
|
||||||
|
uncompressed_source = response.join
|
||||||
|
end
|
||||||
|
minified = compressor.compress(uncompressed_source)
|
||||||
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
||||||
|
response = [minified]
|
||||||
end
|
end
|
||||||
|
|
||||||
[status, headers, response]
|
[status, headers, response]
|
||||||
|
@ -28,4 +33,4 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue