fix js compression. Speed up static asset loading

This commit is contained in:
tdreyno 2011-02-06 10:57:28 -08:00
parent 8bc6714eb1
commit ba7754e7a7
5 changed files with 32 additions and 29 deletions

View file

@ -48,9 +48,10 @@ class Middleman::Server
set :root, Dir.pwd set :root, Dir.pwd
end end
require 'shotgun' # require 'shotgun'
config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru') # config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru')
app = Shotgun.new(config, &lambda { |inner_app| Middleman::Server }) # app = Shotgun.new(config, &lambda { |inner_app| Middleman::Server })
app = Middleman::Server.new
require 'rubygems' require 'rubygems'
require 'thin' require 'thin'

View file

@ -29,7 +29,6 @@ module Middleman
def initialize(*args) def initialize(*args)
Middleman::Server.new Middleman::Server.new
::Tilt.mappings.keys << "js"
super super
end end
@ -41,11 +40,11 @@ module Middleman
end end
def build_static_files def build_static_files
action Directory.new(self, Middleman::Server.public, Middleman::Server.build_dir) action Directory.new(self, Middleman::Server.public, Middleman::Server.build_dir, { :force => true })
end end
def build_dynamic_files def build_dynamic_files
action Directory.new(self, Middleman::Server.views, Middleman::Server.build_dir) action Directory.new(self, Middleman::Server.views, Middleman::Server.build_dir, { :force => true })
end end
@@hooks = {} @@hooks = {}
@ -94,14 +93,13 @@ module Middleman
file_destination.gsub!('/./', '/') file_destination.gsub!('/./', '/')
handled_by_tilt = ::Tilt.mappings.keys.include?(file_extension.gsub(/^\./, "")) handled_by_tilt = ::Tilt.mappings.keys.include?(file_extension.gsub(/^\./, ""))
if handled_by_tilt if handled_by_tilt || (file_extension == ".js")
file_destination.gsub!(file_extension, "") file_destination.gsub!(file_extension, "") unless file_extension == ".js"
destination = base.tilt_template(file_source, file_destination, config, &@block) destination = base.tilt_template(file_source, file_destination, config, &@block)
else else
destination = base.copy_file(file_source, file_destination, config, &@block) destination = base.copy_file(file_source, file_destination, config, &@block)
end end
end end
end end
end end
end end

View file

@ -1,6 +1,9 @@
module Middleman::Features::MinifyJavascript module Middleman::Features::MinifyJavascript
class << self class << self
def registered(app) 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 Middleman::Features::MinifyJavascript::Haml::Javascript.send :include, ::Haml::Filters::Base
require "middleman/features/minify_javascript/rack" require "middleman/features/minify_javascript/rack"

View file

@ -161,7 +161,8 @@ class Middleman::Server
set :app_file, File.expand_path(local_config) set :app_file, File.expand_path(local_config)
end end
use ::Rack::ConditionalGet if environment == :development use ::Rack::ConditionalGet
use ::Rack::Static, :urls => ["/#{self.images_dir}"], :root => "public"
@@run_after_features.each { |block| class_eval(&block) } @@run_after_features.each { |block| class_eval(&block) }

View file

@ -1,3 +1,3 @@
module Middleman module Middleman
VERSION = "1.1.0.beta.3" VERSION = "1.1.0.beta.4"
end end