Created
May 21, 2011 18:01
-
-
Save superchris/984729 to your computer and use it in GitHub Desktop.
asset server initializer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tilt' | |
ENV['COFFEESCRIPT_SOURCE_PATH'] = Rails.root.join( | |
"app", "assets", "javascripts", "vendor", "coffee-script.js") | |
class BareCoffeeScriptTemplate < Sprockets::CoffeeScriptTemplate | |
def evaluate(scope, locals, &block) | |
@output ||= CoffeeScript.compile(data, :bare => true) | |
end | |
end | |
class AssetServer < Sprockets::Environment | |
include Singleton | |
def initialize | |
super Rails.root.join('app', 'assets') | |
paths << 'javascripts' << 'stylesheets' | |
if Rails.env.production? | |
self.js_compressor = YUI::JavaScriptCompressor.new :munge => true, :optimize => true | |
self.css_compressor = YUI::CssCompressor.new | |
end | |
register_engine '.coffee', BareCoffeeScriptTemplate | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment