1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/core_extensions/compass.rb

90 lines
2.9 KiB
Ruby
Raw Normal View History

module Middleman::CoreExtensions::Compass
class << self
def registered(app)
app.extend ClassMethods
require "compass"
# Susy grids
begin
require "susy"
rescue LoadError
end
app.after_feature_init do
# Support a stand-alone compass config file
# Many options are overwritten by Middleman, but the config is a good
# place to add:
# * output_style
# * disable_warnings
# * sass_options
# * line_comments
# * sprite_engine
# * chunky_png_options
compass_config_file = File.join(app.root, "compass.config")
if File.exists?(compass_config_file)
::Compass.add_project_configuration(compass_config_file)
end
::Compass.configuration do |config|
config.project_path = app.root
config.environment = :development
config.cache_path = File.join(app.root, ".sass-cache")
views_root = File.basename(app.views)
config.sass_dir = File.join(views_root, app.css_dir)
config.css_dir = File.join(views_root, app.css_dir)
config.javascripts_dir = File.join(views_root, app.js_dir)
config.fonts_dir = File.join(views_root, app.fonts_dir)
config.images_dir = File.join(views_root, app.images_dir)
if app.respond_to? :http_images_path
config.http_images_path = app.http_images_path
end
if app.respond_to? :http_css_path
config.http_stylesheets_path = app.http_css_path
end
if app.respond_to? :http_js_path
config.http_javascripts_path = app.http_js_path
end
config.asset_cache_buster :none
config.output_style = :nested
config.add_import_path(config.sass_dir)
end
2011-07-13 14:41:59 -04:00
# Required for relative paths
configure :build do
::Compass.configuration do |config|
config.environment = :production
build_root = File.basename(self.build_dir)
config.css_dir = File.join(build_root, self.css_dir)
config.images_dir = File.join(build_root, self.images_dir)
end
end
app.execute_after_compass_init!
app.set :sass, ::Compass.configuration.to_sass_engine_options
end
end
alias :included :registered
end
module ClassMethods
# Add a block/proc to be run after features have been setup
def compass_config(&block)
@run_after_compass ||= []
@run_after_compass << block
end
def execute_after_compass_init!
@run_after_compass ||= []
@run_after_compass.each { |block| block.call(::Compass.configuration) }
end
end
end