remove explicit less.rb support. Switch to uglifyJS for compression.
This commit is contained in:
parent
16667dd88b
commit
7ea1704a64
|
@ -10,7 +10,6 @@ Feature: Builder
|
||||||
Then "services/index.html" should exist and include "Services"
|
Then "services/index.html" should exist and include "Services"
|
||||||
Then "stylesheets/site.css" should exist and include "html, body, div, span"
|
Then "stylesheets/site.css" should exist and include "html, body, div, span"
|
||||||
Then "stylesheets/site_scss.css" should exist and include "html, body, div, span"
|
Then "stylesheets/site_scss.css" should exist and include "html, body, div, span"
|
||||||
Then "stylesheets/test_less.css" should exist and include "666"
|
|
||||||
Then "stylesheets/static.css" should exist and include "body"
|
Then "stylesheets/static.css" should exist and include "body"
|
||||||
Then "_partial.html" should not exist
|
Then "_partial.html" should not exist
|
||||||
And cleanup built test app
|
And cleanup built test app
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
Feature: Support Less CSS
|
|
||||||
In order to offer an alternative when writing CSS
|
|
||||||
|
|
||||||
Scenario: Rendering Less
|
|
||||||
Given the Server is running
|
|
||||||
When I go to "/stylesheets/test_less.css"
|
|
||||||
Then I should see "666"
|
|
|
@ -1,5 +0,0 @@
|
||||||
@brand_color: #666666;
|
|
||||||
|
|
||||||
#header {
|
|
||||||
color: @brand_color;
|
|
||||||
}
|
|
|
@ -3,22 +3,10 @@ module Middleman::Features::MinifyJavascript
|
||||||
def registered(app)
|
def registered(app)
|
||||||
# Only do minification on build or prod mode
|
# Only do minification on build or prod mode
|
||||||
return unless [:build, :production].include? app.environment
|
return unless [:build, :production].include? app.environment
|
||||||
|
|
||||||
Middleman::Features::MinifyJavascript::Haml::Javascript.send :include, ::Haml::Filters::Base
|
|
||||||
|
|
||||||
require "middleman/features/minify_javascript/rack"
|
require "middleman/features/minify_javascript/rack"
|
||||||
app.use Middleman::Rack::MinifyJavascript
|
app.use Middleman::Rack::MinifyJavascript
|
||||||
end
|
end
|
||||||
alias :included :registered
|
alias :included :registered
|
||||||
end
|
end
|
||||||
|
|
||||||
module Haml
|
|
||||||
module Javascript
|
|
||||||
def render_with_options(text, options)
|
|
||||||
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
|
||||||
data = compressor.compress(text)
|
|
||||||
%Q{<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>#{data.chomp}</script>}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
begin
|
begin
|
||||||
require "yui/compressor"
|
require 'uglifier'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
puts "YUI-Compressor not available. Install it with: gem install yui-compressor"
|
puts "UglifyJS not available. Install it with: gem install uglifier"
|
||||||
end
|
end
|
||||||
|
|
||||||
module Middleman
|
module Middleman
|
||||||
|
@ -16,14 +16,14 @@ module Middleman
|
||||||
status, headers, response = @app.call(env)
|
status, headers, response = @app.call(env)
|
||||||
|
|
||||||
if env["PATH_INFO"].match(/\.js$/)
|
if env["PATH_INFO"].match(/\.js$/)
|
||||||
compressor = ::YUI::JavaScriptCompressor.new(:munge => true)
|
compressor = ::Uglifier.new
|
||||||
|
|
||||||
if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile)
|
if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile)
|
||||||
uncompressed_source = File.read(response.path)
|
uncompressed_source = File.read(response.path)
|
||||||
else
|
else
|
||||||
uncompressed_source = response.join
|
uncompressed_source = response.join
|
||||||
end
|
end
|
||||||
minified = compressor.compress(uncompressed_source)
|
minified = compressor.compile(uncompressed_source)
|
||||||
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
|
||||||
response = [minified]
|
response = [minified]
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_runtime_dependency("padrino-core", ["~> 0.9.23"])
|
s.add_runtime_dependency("padrino-core", ["~> 0.9.23"])
|
||||||
s.add_runtime_dependency("padrino-helpers", ["~> 0.9.23"])
|
s.add_runtime_dependency("padrino-helpers", ["~> 0.9.23"])
|
||||||
s.add_runtime_dependency("rack-test", ["~> 0.5.0"])
|
s.add_runtime_dependency("rack-test", ["~> 0.5.0"])
|
||||||
s.add_runtime_dependency("yui-compressor", ["~> 0.9.0"])
|
s.add_runtime_dependency("uglifier", ["~> 0.5.0"])
|
||||||
s.add_runtime_dependency("haml", ["~> 3.1.0"])
|
s.add_runtime_dependency("haml", ["~> 3.1.0"])
|
||||||
s.add_runtime_dependency("sass", ["~> 3.1.0"])
|
s.add_runtime_dependency("sass", ["~> 3.1.0"])
|
||||||
s.add_runtime_dependency("compass", ["~> 0.11.1"])
|
s.add_runtime_dependency("compass", ["~> 0.11.1"])
|
||||||
|
|
Loading…
Reference in a new issue