Merge branch 'v3-stable'
Conflicts: middleman-core/lib/middleman-more/extensions/asset_hash.rb
This commit is contained in:
commit
d7fd48ef7d
3 changed files with 47 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
require 'active_support/core_ext/module/delegation'
|
||||
require 'active_support/core_ext/class/attribute'
|
||||
require 'middleman-core/configuration'
|
||||
|
||||
module Middleman
|
||||
# Middleman's Extension API provides the ability to add functionality to Middleman
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#
|
||||
class Middleman::Extensions::Gzip < ::Middleman::Extension
|
||||
option :exts, %w(.js .css .html .htm), 'File extensions to Gzip when building.'
|
||||
option :ignore, [], 'Patterns to avoid gzipping'
|
||||
|
||||
class NumberHelpers
|
||||
include ::Padrino::Helpers::NumberHelpers
|
||||
|
@ -33,7 +34,7 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|||
# Fill a queue with inputs
|
||||
in_queue = Queue.new
|
||||
paths.each do |path|
|
||||
in_queue << path if options.exts.include?(path.extname)
|
||||
in_queue << path if should_gzip?(path)
|
||||
end
|
||||
num_paths = in_queue.size
|
||||
|
||||
|
@ -97,4 +98,13 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|||
|
||||
[output_filename, old_size, new_size]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Whether a path should be gzipped
|
||||
# @param [Pathname] path A destination path
|
||||
# @return [Boolean]
|
||||
def should_gzip?(path)
|
||||
options.exts.include?(path.extname) && options.ignore.none? { |ignore| Middleman::Util.path_match(ignore, path.to_s) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue