-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
66 lines (57 loc) · 1.73 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'rubygems'
require 'bundler'
Bundler.require
sprockets = Sprockets::Environment.new
sprockets.append_path "assets/source/javascripts"
sprockets.append_path "assets/source/stylesheets"
# CONFIG
sass = ['settings.css.sass']
coffee = ['settings.js.coffee']
# TASKS
namespace :build do
desc "Clean output directories"
task :clean do
rmtree "assets/build"
mkdir "assets/build"
mkdir "assets/build/javascripts"
mkdir "assets/build/stylesheets"
end
desc "Build for development"
task :development => :clean do
sass.each do |input|
print "Building Sass... "
output = canonical_filename(input)
bundle = sprockets[input].to_s
File.open("assets/build/stylesheets/#{output}", 'w') { |f| f.write bundle }
puts "ok"
end
coffee.each do |input|
print "Building CoffeeScript... "
output = canonical_filename(input)
bundle = sprockets[input].to_s
File.open("assets/build/javascripts/#{output}", 'w') { |f| f.write bundle }
puts "ok"
end
end
desc "Build for production (minified files)"
task :production => :clean do
sass.each do |input|
print "Building Sass... "
output = canonical_filename(input)
bundle = sprockets[input].to_s
File.open("assets/build/stylesheets/#{output}", 'w') { |f| f.write bundle }
puts "ok"
end
coffee.each do |input|
print "Building CoffeeScript... "
output = canonical_filename(input)
bundle = sprockets[input].to_s
File.open("assets/build/javascripts/#{output}", 'w') { |f| f.write Uglifier.compile(bundle) }
puts "ok"
end
end
end
task :default => "build:development"
def canonical_filename(filename)
filename.chomp(".coffee").chomp(".sass").chomp(".sass")
end