use build? helper

This commit is contained in:
Thomas Reynolds 2011-07-10 15:13:00 -07:00
parent 01eccafde2
commit 142e6b9f24
5 changed files with 5 additions and 4 deletions

View file

@ -16,7 +16,7 @@ module Middleman::Features::CacheBuster
if File.readable?(real_path_static)
http_path << "?" + File.mtime(real_path_static).strftime("%s")
elsif app.environment == :build
elsif app.build?
real_path_dynamic = File.join(app.root, app.build_dir, prefix, path)
http_path << "?" + File.mtime(real_path_dynamic).strftime("%s") if File.readable?(real_path_dynamic)
end

View file

@ -1,7 +1,7 @@
module Middleman::Features::LiveReload
class << self
def registered(app)
return unless Middleman::Server.environment == :development
return unless Middleman::Server.development?
begin
require 'livereload'

View file

@ -2,7 +2,7 @@ module Middleman::Features::MinifyJavascript
class << self
def registered(app)
# Only do minification on build or prod mode
return unless [:build, :production].include? app.environment
return unless app.build? || app.production?
require "middleman/features/minify_javascript/rack"
app.use Middleman::Rack::MinifyJavascript

View file

@ -14,7 +14,7 @@ module Middleman::Renderers::Sass
def sass_options
return super if basename.nil?
location_of_sass_file = if Middleman::Server.environment == :build
location_of_sass_file = if Middleman::Server.build?
File.join(Middleman::Server.root, Middleman::Server.build_dir)
else
Middleman::Server.views

View file

@ -14,6 +14,7 @@ module Middleman
super(option, value, &nil)
end
# Convenience method to check if we're in build mode
def build?; environment == :build; end
end