forked from flamejs/flame.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
77 lines (62 loc) · 2.1 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
67
68
69
70
71
72
73
74
75
76
77
require 'sprockets'
require 'sprockets-sass'
require 'sass'
require 'uglifier'
task :default => [:build]
task :build => :clean do
ENV['image_path'] ||= ''
if defined?(Sass)
module Sass::Script::Functions
# returns an IE hex string for a color with an alpha channel
# suitable for passing to IE filters.
# from Compass (http://compass-style.org)
def ie_hex_str(color)
assert_type color, :Color
alpha = (color.alpha * 255).round
alphastr = alpha.to_s(16).rjust(2, '0')
Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
end
declare :ie_hex_str, [:color]
end
end
# Used by image-url in sass
def image_path(image, options={})
image_path = ENV['image_path'].dup
image_path << '/' unless image_path =~ /(\/$)|(^$)/
image_path = '../' if image_path == ''
"#{image_path}#{image}"
end
public :image_path
environment = Sprockets::Environment.new
environment.append_path('.')
environment.append_path('vendor')
environment.append_path('stylesheets')
assets = environment.find_asset('flame.js')
assets.write_to('build/flame.js')
flame = File.open('build/flame.min.js', 'w')
flame.write(Uglifier.compile(File.read('build/flame.js').gsub(%r{^(\s)+Ember\.assert\((.*)\).*$}, '')))
flame.close
html5 = environment.find_asset('html5.js')
html5.write_to('build/html5.js')
# Flame Inspector
inspector_js = environment.find_asset('flame_inspector.js')
inspector_js.write_to('build/flame_inspector.js')
inspector_css = environment.find_asset('flame_inspector.css.scss')
inspector_css.write_to('build/stylesheets/flame_inspector.css')
# SCSS files
css = environment.find_asset('flame.css.scss')
css.write_to('build/stylesheets/flame.css')
# Copy over images directory
FileUtils.copy_entry('images', 'build/images')
end
task :clean do
FileUtils.rm_rf('build')
end
task :jshint do
files = Rake::FileList.new('**/*.js').
exclude('build/**/*.js').
exclude('vendor/**/*.js')
sh "jshint #{files.join(' ')}" do |ok, res|
fail 'JSHint found errors.' unless ok
end
end