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
|
||||
===
|
||||
|
||||
* 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).
|
||||
* Prevent local templates being loaded when $HOME is not set
|
||||
* Removed "Implied Extension feature"
|
||||
|
|
|
@ -36,9 +36,7 @@ Feature: Minify CSS
|
|||
end
|
||||
end
|
||||
|
||||
activate :minify_css
|
||||
|
||||
set :css_compressor, ::PassThrough
|
||||
activate :minify_css, :compressor => ::PassThrough
|
||||
"""
|
||||
And the Server is running at "passthrough-app"
|
||||
When I go to "/stylesheets/site.css"
|
||||
|
@ -71,9 +69,7 @@ Feature: Minify CSS
|
|||
end
|
||||
end
|
||||
|
||||
activate :minify_css, :inline => true
|
||||
|
||||
set :css_compressor, ::PassThrough
|
||||
activate :minify_css, :inline => true, :compressor => ::PassThrough
|
||||
|
||||
page "/inline-css.html", :layout => false
|
||||
"""
|
||||
|
|
|
@ -49,9 +49,7 @@ Feature: Minify Javascript
|
|||
end
|
||||
end
|
||||
|
||||
activate :minify_javascript, :inline => true
|
||||
|
||||
set :js_compressor, ::PassThrough
|
||||
activate :minify_javascript, :inline => true, :compressor => ::PassThrough
|
||||
|
||||
page "/inline-js.html", :layout => false
|
||||
"""
|
||||
|
@ -195,9 +193,7 @@ Feature: Minify Javascript
|
|||
end
|
||||
end
|
||||
|
||||
activate :minify_javascript, :inline => true
|
||||
|
||||
set :js_compressor, ::PassThrough
|
||||
activate :minify_javascript, :inline => true, :compressor => ::PassThrough
|
||||
|
||||
page "/inline-coffeescript.html", :layout => false
|
||||
"""
|
||||
|
@ -215,9 +211,7 @@ Feature: Minify Javascript
|
|||
end
|
||||
end
|
||||
|
||||
activate :minify_javascript
|
||||
|
||||
set :js_compressor, ::PassThrough
|
||||
activate :minify_javascript, :compressor => ::PassThrough
|
||||
"""
|
||||
And the Server is running at "passthrough-app"
|
||||
When I go to "/javascripts/coffee_test.js"
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
# Minify CSS 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 :ignore, [], 'Patterns to avoid minifying'
|
||||
|
||||
def initialize(app, options_hash={}, &block)
|
||||
super
|
||||
|
||||
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
|
||||
option :compressor, Proc.new {
|
||||
require 'sass'
|
||||
SassCompressor
|
||||
}, 'Set the CSS compressor to use.'
|
||||
|
||||
def after_configuration
|
||||
chosen_compressor = app.config[:css_compressor] || options[:compressor] || SassCompressor
|
||||
|
||||
# Setup Rack middleware to minify CSS
|
||||
app.use Rack, :compressor => chosen_compressor,
|
||||
app.use Rack, :compressor => options[:compressor],
|
||||
:ignore => Array(options[:ignore]) + [/\.min\./],
|
||||
:inline => options[:inline]
|
||||
end
|
||||
|
@ -36,9 +31,12 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|||
# @param [Hash] options
|
||||
def initialize(app, options={})
|
||||
@app = app
|
||||
@compressor = options[:compressor]
|
||||
@ignore = options[:ignore]
|
||||
@inline = options[:inline]
|
||||
@ignore = options.fetch(:ignore)
|
||||
@inline = options.fetch(:inline)
|
||||
|
||||
@compressor = options.fetch(:compressor)
|
||||
@compressor = @compressor.to_proc if @compressor.respond_to? :to_proc
|
||||
@compressor = @compressor.call if @compressor.is_a? Proc
|
||||
end
|
||||
|
||||
# Rack interface
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
# Minify Javascript 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 :ignore, [], 'Patterns to avoid minifying'
|
||||
|
||||
def initialize(app, options_hash={}, &block)
|
||||
super
|
||||
|
||||
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
|
||||
option :compressor, Proc.new {
|
||||
require 'uglifier'
|
||||
::Uglifier.new
|
||||
}, 'Set the JS compressor to use.'
|
||||
|
||||
def after_configuration
|
||||
chosen_compressor = app.config[:js_compressor] || options[:compressor] || begin
|
||||
require 'uglifier'
|
||||
::Uglifier.new
|
||||
end
|
||||
|
||||
# Setup Rack middleware to minify CSS
|
||||
app.use Rack, :compressor => chosen_compressor,
|
||||
app.use Rack, :compressor => options[:compressor],
|
||||
:ignore => Array(options[:ignore]) + [/\.min\./],
|
||||
:inline => options[:inline]
|
||||
end
|
||||
|
@ -30,9 +22,12 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|||
# @param [Hash] options
|
||||
def initialize(app, options={})
|
||||
@app = app
|
||||
@compressor = options[:compressor]
|
||||
@ignore = options[:ignore]
|
||||
@inline = options[:inline]
|
||||
@ignore = options.fetch(:ignore)
|
||||
@inline = options.fetch(:inline)
|
||||
|
||||
@compressor = options.fetch(:compressor)
|
||||
@compressor = @compressor.to_proc if @compressor.respond_to? :to_proc
|
||||
@compressor = @compressor.call if @compressor.is_a? Proc
|
||||
end
|
||||
|
||||
# Rack interface
|
||||
|
|
Loading…
Add table
Reference in a new issue