remove explicit less.rb support. Switch to uglifyJS for compression.

This commit is contained in:
Thomas Reynolds 2011-04-26 23:03:25 -07:00
parent 16667dd88b
commit 7ea1704a64
6 changed files with 5 additions and 30 deletions

View file

@ -10,7 +10,6 @@ Feature: Builder
Then "services/index.html" should exist and include "Services"
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/test_less.css" should exist and include "666"
Then "stylesheets/static.css" should exist and include "body"
Then "_partial.html" should not exist
And cleanup built test app

View file

@ -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"

View file

@ -1,5 +0,0 @@
@brand_color: #666666;
#header {
color: @brand_color;
}

View file

@ -3,22 +3,10 @@ module Middleman::Features::MinifyJavascript
def registered(app)
# Only do minification on build or prod mode
return unless [:build, :production].include? app.environment
Middleman::Features::MinifyJavascript::Haml::Javascript.send :include, ::Haml::Filters::Base
require "middleman/features/minify_javascript/rack"
app.use Middleman::Rack::MinifyJavascript
end
alias :included :registered
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

View file

@ -1,7 +1,7 @@
begin
require "yui/compressor"
require 'uglifier'
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
module Middleman
@ -16,14 +16,14 @@ module Middleman
status, headers, response = @app.call(env)
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)
uncompressed_source = File.read(response.path)
else
uncompressed_source = response.join
end
minified = compressor.compress(uncompressed_source)
minified = compressor.compile(uncompressed_source)
headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s
response = [minified]
end

View file

@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("padrino-core", ["~> 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("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("sass", ["~> 3.1.0"])
s.add_runtime_dependency("compass", ["~> 0.11.1"])