forked from alexch/codelikethis
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRakefile
More file actions
76 lines (65 loc) · 1.74 KB
/
Rakefile
File metadata and controls
76 lines (65 loc) · 1.74 KB
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
require 'rspec/core/rake_task'
require 'rake/notes/rake_task'
require 'sassc'
task :default => :spec
desc "run tests"
RSpec::Core::RakeTask.new do |task|
task.pattern = "spec/**/*_spec.rb"
task.rspec_opts = [
'-f documentation',
'-r ./rspec_config'
]
task.verbose = false
end
task :build_css do
public_dir = 'public'
css_dir = File.join public_dir, 'css'
sass_dir = File.join public_dir, 'scss'
bootstrap_dir = File.join sass_dir, 'bootstrap-4.3.1/scss'
puts 'Building CSS...'
scss_path = File.join(sass_dir, 'app.scss')
css_path = File.join(css_dir, 'app.css')
source_map_path = File.join(css_dir, 'app.css.map')
if !File.exist?(css_path) || File.mtime(scss_path) > File.mtime(css_path)
scss = File.new(scss_path).read
engine = SassC::Engine.new(
scss,
style: :compressed,
load_paths: [bootstrap_dir],
source_map_file: source_map_path,
source_map_contents: true
)
css_output = engine.render
output_file = File.new(css_path, 'w')
output_file.write(css_output)
source_map = engine.source_map
source_map_file = File.new(source_map_path, 'w')
source_map_file.write(source_map)
else
puts 'Skipping CSS build; to force build, do this:'
puts "touch #{scss_path}"
end
end
desc "build app"
task :build => [
:build_css] do
puts "Built."
end
desc "run app and keep building and running it"
task :rerun do
cmd = %w{bundle exec rerun -- rackup}
sh *cmd
end
desc "run app"
task :run => :build do
sh "bundle exec rackup"
end
desc "clean"
task :clean do
public_dir = "public"
css_dir = File.join public_dir, "css"
css_file = File.join(css_dir, "app.css")
map_file = File.join(css_dir,"app.css.map")
File.delete(css_file)
File.delete(map_file)
end