mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Allow compressor to be passed to minify extensions as an activate option
This commit is contained in:
parent
240f67410d
commit
cc3aebf5cc
4 changed files with 66 additions and 7 deletions
|
@ -22,7 +22,7 @@ Feature: Minify CSS
|
||||||
Then I should see "1" lines
|
Then I should see "1" lines
|
||||||
And I should see "only screen and (device-width"
|
And I should see "only screen and (device-width"
|
||||||
When I go to "/more-css/site.css"
|
When I go to "/more-css/site.css"
|
||||||
Then I should see "1" lines
|
Then I should see "1" lines
|
||||||
|
|
||||||
Scenario: Rendering external css with passthrough compressor
|
Scenario: Rendering external css with passthrough compressor
|
||||||
Given a fixture app "passthrough-app"
|
Given a fixture app "passthrough-app"
|
||||||
|
@ -88,6 +88,29 @@ Feature: Minify CSS
|
||||||
</style>
|
</style>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: Rendering inline css with a passthrough minifier using activate-style compressor
|
||||||
|
Given a fixture app "passthrough-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
module ::HelloCompressor
|
||||||
|
def self.compress(data)
|
||||||
|
"Hello"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
activate :minify_css, :inline => true, :compressor => ::HelloCompressor
|
||||||
|
|
||||||
|
page "/inline-css.html", :layout => false
|
||||||
|
"""
|
||||||
|
And the Server is running at "passthrough-app"
|
||||||
|
When I go to "/inline-css.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<style type='text/css'>
|
||||||
|
Hello
|
||||||
|
</style>
|
||||||
|
"""
|
||||||
|
|
||||||
Scenario: Rendering inline css with the feature enabled
|
Scenario: Rendering inline css with the feature enabled
|
||||||
Given a fixture app "minify-css-app"
|
Given a fixture app "minify-css-app"
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
|
|
|
@ -92,6 +92,42 @@ Feature: Minify Javascript
|
||||||
</script>
|
</script>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: Rendering inline css with a passthrough minifier using activate-style compressor
|
||||||
|
Given a fixture app "passthrough-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
module ::HelloCompressor
|
||||||
|
def self.compress(data)
|
||||||
|
"Hello"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
activate :minify_javascript, :inline => true, :compressor => ::HelloCompressor
|
||||||
|
|
||||||
|
page "/inline-js.html", :layout => false
|
||||||
|
"""
|
||||||
|
And the Server is running at "passthrough-app"
|
||||||
|
When I go to "/inline-js.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<script type='text/javascript'>
|
||||||
|
//<![CDATA[
|
||||||
|
Hello
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
Hello
|
||||||
|
</script>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
//<!--
|
||||||
|
Hello
|
||||||
|
//-->
|
||||||
|
</script>
|
||||||
|
<script type='text/html'>
|
||||||
|
I'm a jQuery {{template}}.
|
||||||
|
</script>
|
||||||
|
"""
|
||||||
|
|
||||||
Scenario: Rendering inline js with the feature enabled
|
Scenario: Rendering inline js with the feature enabled
|
||||||
Given a fixture app "minify-js-app"
|
Given a fixture app "minify-js-app"
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
|
|
|
@ -15,13 +15,13 @@ module Middleman::Extensions
|
||||||
inline = options[:inline] || false
|
inline = options[:inline] || false
|
||||||
|
|
||||||
app.after_configuration do
|
app.after_configuration do
|
||||||
unless respond_to?(:css_compressor) && css_compressor
|
chosen_compressor = css_compressor || options[:compressor] || begin
|
||||||
require "middleman-more/extensions/minify_css/rainpress"
|
require "middleman-more/extensions/minify_css/rainpress"
|
||||||
set :css_compressor, ::Rainpress
|
::Rainpress
|
||||||
end
|
end
|
||||||
|
|
||||||
# Setup Rack middleware to minify CSS
|
# Setup Rack middleware to minify CSS
|
||||||
use MinifyCSSRack, :compressor => css_compressor,
|
use MinifyCSSRack, :compressor => chosen_compressor,
|
||||||
:ignore => ignore,
|
:ignore => ignore,
|
||||||
:inline => inline
|
:inline => inline
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,13 +16,13 @@ module Middleman::Extensions
|
||||||
|
|
||||||
# Once config is parsed
|
# Once config is parsed
|
||||||
app.after_configuration do
|
app.after_configuration do
|
||||||
unless respond_to?(:js_compressor) && js_compressor
|
chosen_compressor = js_compressor || options[:compressor] || begin
|
||||||
require 'uglifier'
|
require 'uglifier'
|
||||||
set :js_compressor, ::Uglifier.new
|
::Uglifier.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# Setup Rack middlware to minify JS
|
# Setup Rack middlware to minify JS
|
||||||
use MinifyJavascriptRack, :compressor => js_compressor,
|
use MinifyJavascriptRack, :compressor => chosen_compressor,
|
||||||
:ignore => ignore,
|
:ignore => ignore,
|
||||||
:inline => inline
|
:inline => inline
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue