forked from HashNuke/mogo-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
63 lines (50 loc) · 1.32 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
require 'sprockets'
require 'rake/sprocketstask'
require 'uglifier'
require 'bourbon'
require 'filewatcher'
sprockets = Sprockets::Environment.new("./") do |env|
env.logger = Logger.new(STDOUT)
env.append_path 'assets/javascripts'
env.append_path 'assets/stylesheets'
env.append_path 'assets/images'
unless ENV["MIX_ENV"] == "dev"
env.js_compressor = Uglifier.new
env.css_compressor = :scss
end
end
assets = %w( application.js application.css )
asset_output = "priv/static/assets"
extra_dirs = ["images"]
extra_dirs.each do |dir|
Dir.glob("assets/#{dir}/*.*") do |f|
assets.push File.basename(f)
end
end
namespace :assets do
desc "Compile assets"
task :compile do
begin
assets.each do |asset|
puts asset
sprockets[asset].write_to "#{asset_output}/#{asset}"
end
rescue => e
puts "Error #{e.inspect}"
end
end
desc "Watch assets for changes and compile"
task :watch do
watch_list = ["assets/javascripts/", "assets/stylesheets/", "assets/images/"]
FileWatcher.new(watch_list, "Watching assets for compliation...").watch do |filename|
begin
assets.each do |asset|
puts asset
sprockets[asset].write_to "#{asset_output}/#{asset}"
end
rescue => e
puts "Error #{e.inspect}"
end
end
end
end