Created
January 2, 2012 02:53
-
-
Save bobspryn/1549100 to your computer and use it in GitHub Desktop.
AssetFile
This file contains 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 "json" | |
require "uglifier" | |
require "rake-pipeline-web-filters" | |
# this gives you concat, coffee_script, and minispade methods | |
require "rake-pipeline-web-filters/helpers" | |
class HandlebarsFilter < Rake::Pipeline::Filter | |
def initialize(&block) | |
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') } | |
super(&block) | |
end | |
def generate_output(inputs, output) | |
inputs.each do |input| | |
output.write "return Ember.Handlebars.compile(#{input.read.to_json})" | |
end | |
end | |
end | |
# process all js, css and html files in app/assets | |
input "assets" | |
# processed files should be outputted to public | |
output "public" | |
# process all coffee files | |
match "**/*.coffee" do | |
# compile all CoffeeScript files. the output file | |
# for the compilation should be the input name | |
# with the .coffee extension replaced with .js | |
coffee_script | |
# The coffee_script helper is exactly equivalent to: | |
# filter Rake::Pipeline::Web::Filters::CoffeeScriptCompiler | |
end | |
match "**/*.js" do | |
minispade :module_id_generator => proc { |input| input.path.sub(/js\//, '').sub(/\.js$/, '') } | |
if ENV['RAKEP_ENV'] == "production" | |
uglify | |
concat "application.js" | |
else | |
concat | |
end | |
end | |
match "**/*.handlebars" do | |
filter HandlebarsFilter | |
minispade :module_id_generator => proc { |input| input.path.sub(/templates\//, 't/').sub(/\.js$/, '') } | |
if ENV['RAKEP_ENV'] == "production" | |
uglify | |
end | |
concat "templates.js" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment