Skip to content

Instantly share code, notes, and snippets.

@superchris
Created May 21, 2011 18:01
Show Gist options
  • Save superchris/984729 to your computer and use it in GitHub Desktop.
Save superchris/984729 to your computer and use it in GitHub Desktop.
asset server initializer
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