Remove root config options for minification
This commit is contained in:
parent
1840176340
commit
ffe9226aac
5 changed files with 29 additions and 44 deletions
|
@ -1,6 +1,8 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
|
* Removed `css_compressor` setting, use `activate :minify_css, :compressor =>` instead.
|
||||||
|
* Removed `js_compressor` setting, use `activate :minify_javascript, :compressor =>` instead.
|
||||||
* Removed ability to server folders of content statically (non-Middleman projects).
|
* Removed ability to server folders of content statically (non-Middleman projects).
|
||||||
* Prevent local templates being loaded when $HOME is not set
|
* Prevent local templates being loaded when $HOME is not set
|
||||||
* Removed "Implied Extension feature"
|
* Removed "Implied Extension feature"
|
||||||
|
|
|
@ -36,9 +36,7 @@ Feature: Minify CSS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
activate :minify_css
|
activate :minify_css, :compressor => ::PassThrough
|
||||||
|
|
||||||
set :css_compressor, ::PassThrough
|
|
||||||
"""
|
"""
|
||||||
And the Server is running at "passthrough-app"
|
And the Server is running at "passthrough-app"
|
||||||
When I go to "/stylesheets/site.css"
|
When I go to "/stylesheets/site.css"
|
||||||
|
@ -71,9 +69,7 @@ Feature: Minify CSS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
activate :minify_css, :inline => true
|
activate :minify_css, :inline => true, :compressor => ::PassThrough
|
||||||
|
|
||||||
set :css_compressor, ::PassThrough
|
|
||||||
|
|
||||||
page "/inline-css.html", :layout => false
|
page "/inline-css.html", :layout => false
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -49,9 +49,7 @@ Feature: Minify Javascript
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
activate :minify_javascript, :inline => true
|
activate :minify_javascript, :inline => true, :compressor => ::PassThrough
|
||||||
|
|
||||||
set :js_compressor, ::PassThrough
|
|
||||||
|
|
||||||
page "/inline-js.html", :layout => false
|
page "/inline-js.html", :layout => false
|
||||||
"""
|
"""
|
||||||
|
@ -195,9 +193,7 @@ Feature: Minify Javascript
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
activate :minify_javascript, :inline => true
|
activate :minify_javascript, :inline => true, :compressor => ::PassThrough
|
||||||
|
|
||||||
set :js_compressor, ::PassThrough
|
|
||||||
|
|
||||||
page "/inline-coffeescript.html", :layout => false
|
page "/inline-coffeescript.html", :layout => false
|
||||||
"""
|
"""
|
||||||
|
@ -215,9 +211,7 @@ Feature: Minify Javascript
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
activate :minify_javascript
|
activate :minify_javascript, :compressor => ::PassThrough
|
||||||
|
|
||||||
set :js_compressor, ::PassThrough
|
|
||||||
"""
|
"""
|
||||||
And the Server is running at "passthrough-app"
|
And the Server is running at "passthrough-app"
|
||||||
When I go to "/javascripts/coffee_test.js"
|
When I go to "/javascripts/coffee_test.js"
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
# Minify CSS Extension
|
# Minify CSS Extension
|
||||||
class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
||||||
option :compressor, nil, 'Set the CSS compressor to use.'
|
|
||||||
option :inline, false, 'Whether to minify CSS inline within HTML files'
|
option :inline, false, 'Whether to minify CSS inline within HTML files'
|
||||||
option :ignore, [], 'Patterns to avoid minifying'
|
option :ignore, [], 'Patterns to avoid minifying'
|
||||||
|
option :compressor, Proc.new {
|
||||||
def initialize(app, options_hash={}, &block)
|
require 'sass'
|
||||||
super
|
SassCompressor
|
||||||
|
}, 'Set the CSS compressor to use.'
|
||||||
app.config.define_setting :css_compressor, nil, 'Set the CSS compressor to use. Deprecated in favor of the :compressor option when activating :minify_css'
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_configuration
|
def after_configuration
|
||||||
chosen_compressor = app.config[:css_compressor] || options[:compressor] || SassCompressor
|
|
||||||
|
|
||||||
# Setup Rack middleware to minify CSS
|
# Setup Rack middleware to minify CSS
|
||||||
app.use Rack, :compressor => chosen_compressor,
|
app.use Rack, :compressor => options[:compressor],
|
||||||
:ignore => Array(options[:ignore]) + [/\.min\./],
|
:ignore => Array(options[:ignore]) + [/\.min\./],
|
||||||
:inline => options[:inline]
|
:inline => options[:inline]
|
||||||
end
|
end
|
||||||
|
@ -36,9 +31,12 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
||||||
# @param [Hash] options
|
# @param [Hash] options
|
||||||
def initialize(app, options={})
|
def initialize(app, options={})
|
||||||
@app = app
|
@app = app
|
||||||
@compressor = options[:compressor]
|
@ignore = options.fetch(:ignore)
|
||||||
@ignore = options[:ignore]
|
@inline = options.fetch(:inline)
|
||||||
@inline = options[:inline]
|
|
||||||
|
@compressor = options.fetch(:compressor)
|
||||||
|
@compressor = @compressor.to_proc if @compressor.respond_to? :to_proc
|
||||||
|
@compressor = @compressor.call if @compressor.is_a? Proc
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rack interface
|
# Rack interface
|
||||||
|
|
|
@ -1,23 +1,15 @@
|
||||||
# Minify Javascript Extension
|
# Minify Javascript Extension
|
||||||
class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
||||||
option :compressor, nil, 'Set the JS compressor to use.'
|
|
||||||
option :inline, false, 'Whether to minify JS inline within HTML files'
|
option :inline, false, 'Whether to minify JS inline within HTML files'
|
||||||
option :ignore, [], 'Patterns to avoid minifying'
|
option :ignore, [], 'Patterns to avoid minifying'
|
||||||
|
option :compressor, Proc.new {
|
||||||
def initialize(app, options_hash={}, &block)
|
require 'uglifier'
|
||||||
super
|
::Uglifier.new
|
||||||
|
}, 'Set the JS compressor to use.'
|
||||||
app.config.define_setting :js_compressor, nil, 'Set the JS compressor to use. Deprecated in favor of the :compressor option when activating :minify_js'
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_configuration
|
def after_configuration
|
||||||
chosen_compressor = app.config[:js_compressor] || options[:compressor] || begin
|
|
||||||
require 'uglifier'
|
|
||||||
::Uglifier.new
|
|
||||||
end
|
|
||||||
|
|
||||||
# Setup Rack middleware to minify CSS
|
# Setup Rack middleware to minify CSS
|
||||||
app.use Rack, :compressor => chosen_compressor,
|
app.use Rack, :compressor => options[:compressor],
|
||||||
:ignore => Array(options[:ignore]) + [/\.min\./],
|
:ignore => Array(options[:ignore]) + [/\.min\./],
|
||||||
:inline => options[:inline]
|
:inline => options[:inline]
|
||||||
end
|
end
|
||||||
|
@ -30,9 +22,12 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
||||||
# @param [Hash] options
|
# @param [Hash] options
|
||||||
def initialize(app, options={})
|
def initialize(app, options={})
|
||||||
@app = app
|
@app = app
|
||||||
@compressor = options[:compressor]
|
@ignore = options.fetch(:ignore)
|
||||||
@ignore = options[:ignore]
|
@inline = options.fetch(:inline)
|
||||||
@inline = options[:inline]
|
|
||||||
|
@compressor = options.fetch(:compressor)
|
||||||
|
@compressor = @compressor.to_proc if @compressor.respond_to? :to_proc
|
||||||
|
@compressor = @compressor.call if @compressor.is_a? Proc
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rack interface
|
# Rack interface
|
||||||
|
|
Loading…
Add table
Reference in a new issue