Skip to content

@joewest /Assetfile forked from dudleyf/Assetfile
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
APPNAME = 'wh'
require 'json'
require 'rake-pipeline-web-filters'
WebFilters = Rake::Pipeline::Web::Filters
class LoaderFilter < WebFilters::MinispadeFilter
def generate_output(inputs, output)
inputs.each do |input|
code = input.read
module_id = @module_id_generator.call(input)
contents = "function(require) {\n#{code}\n}"
ret = "\nloader.register('#{module_id}', #{contents});\n"
output.write ret
end
end
end
class EmberAssertFilter < Filter
def generate_output(inputs, output)
inputs.each do |input|
result = input.read
result.gsub!(/ember_assert\((.*)\);/, '')
output.write(result)
end
end
end
class HandlebarsFilter < Filter
def generate_output(inputs, output)
inputs.each do |input|
code = input.read.to_json
name = File.basename(input.path, '.handlebars')
output.write "\nreturn Ember.Handlebars.compile(#{code});\n"
end
end
end
output 'public'
input 'app' do
match 'lib/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'assets/app.js'
end
match 'vendor/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^vendor\//, '').sub(/\.js$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat %w[
vendor/jquery.js
vendor/ember.js
vendor/sproutcore-routing.js
], 'assets/app.js'
end
match 'modules/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'assets/app.js'
end
match 'plugins/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat do |input|
input.sub(/plugins\//, 'assets/')
end
end
match 'templates/**/*.handlebars' do
filter HandlebarsFilter
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^templates\//, "#{APPNAME}/~templates/").sub(/\.handlebars$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat 'assets/app.js'
end
match 'tests/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
}
concat 'assets/app-tests.js'
end
match 'css/**/*.css' do
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat ['bootstrap.css', 'main.css'], 'assets/app.css'
end
match 'css/**/*.scss' do
sass
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat 'assets/app.css'
end
match "static/**/*" do
concat do |input|
input.sub(/static\//, '')
end
end
end
# vim: filetype=ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.