-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
60 lines (47 loc) · 1.43 KB
/
Rakefile
File metadata and controls
60 lines (47 loc) · 1.43 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
# frozen_string_literal: true
require "vite_ruby"
ViteRuby.install_tasks
desc "Precompile assets"
task :environment do
require "./config/boot"
Staticky.configure do |config|
config.env = ENV.fetch("RACK_ENV", "development").to_sym
end
Staticky.application.monitor(:builder, methods: %i[call]) do |event|
Staticky.logger.info "Built site in #{event[:time]}ms"
end
end
namespace :site do
desc "Build the site assets"
task :build_assets do
next unless Staticky.env.production?
Staticky.logger.info "Precompiling assets..."
Rake::Task["vite:build"].execute
end
desc "Build the site and its assets into the Staticky.build_path (./build)"
task build: %i[environment build_assets] do
Staticky.logger.info "Building site in #{Staticky.env.name} environment..."
Staticky.builder.call
end
desc "Watch the site and its assets for changes"
task watch: :environment do
require "filewatcher"
Rake::Task["site:build"].execute unless Staticky.build_path.exist?
Staticky.logger.info "Watching site in #{Staticky.env.name} environment..."
Filewatcher.new(
[
"app/**/*.rb",
"lib/**/*.rb",
"content/**/*"
]
).watch do
Staticky.logger.info "Change detected, rebuilding site..."
sh("bin/rake site:build") do |ok, res|
unless ok
Staticky.logger.error "Error rebuilding site:"
puts res
end
end
end
end
end