forked from tent/tentd-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
40 lines (34 loc) · 1.2 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'bundler/gem_tasks'
require 'bundler/setup'
require 'rake/sprocketstask'
require 'tentd-admin/sprockets/environment'
require 'uglifier'
namespace :assets do
Rake::SprocketsTask.new do |t|
t.environment = Sprockets::Environment.new
%w{ javascripts stylesheets images }.each do |path|
t.environment.append_path("assets/#{path}")
end
t.environment.js_compressor = Uglifier.new
t.output = "./public/assets"
t.assets = %w( application.js application.css chosen-sprite.png )
t.manifest = lambda { Sprockets::Manifest.new(t.environment, "./public/assets", "./public/assets/manifest.json") }
t.environment.context_class.class_eval do
include SprocketsHelpers
end
end
task :gzip_assets => :assets do
Dir['public/assets/**/*.*'].reject { |f| f =~ /\.gz\z/ }.each do |f|
sh "gzip -c #{f} > #{f}.gz" unless File.exist?("#{f}.gz")
end
end
task :deploy_assets => :gzip_assets do
if ENV['S3_BUCKET'] && ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
require './config/asset_sync'
AssetSync.sync
end
end
# deploy assets when deploying to heroku
task :precompile => :deploy_assets
end
require 'tentd/tasks/db'