al-quran.reflectslight.io/tasks/nanoc.rake

42 lines
1,010 B
Ruby
Raw Normal View History

2023-07-25 20:32:57 +02:00
namespace :nanoc do
require "bundler/setup"
cwd = File.realpath File.join(__dir__, "..")
2023-07-25 20:32:57 +02:00
desc "Clean the build/ directory"
2023-07-25 20:32:57 +02:00
task :clean do
Dir.chdir(cwd) do
sh "rm -rf node_modules/.cache/"
2024-02-24 02:38:50 +01:00
sh "rm -rf tmp/"
sh "rm -rf build"
end
2023-07-25 20:32:57 +02:00
end
desc "Produce the build/ directory"
task :build, [:buildenv] do |t, args|
2024-02-18 22:01:55 +01:00
Dir.chdir(cwd) do
buildenv = args.buildenv || ENV["buildenv"] || "development"
2024-02-18 22:01:55 +01:00
sass_path = File.join(cwd, "src", "css")
2024-02-24 00:58:28 +01:00
sh "rm -rf build/al-quran/css/"
Bundler.with_unbundled_env {
2024-02-18 22:01:55 +01:00
sh "SASS_PATH=#{sass_path} buildenv=#{buildenv} bundle exec nanoc co"
}
end
end
desc "Produce the build/ directory on-demand"
task watch: ['nanoc:build'] do
Dir.chdir(cwd) do
require "listen"
path = File.join(Dir.getwd, "src")
Listen.to(path) do
Bundler.with_unbundled_env { sh "rake nanoc:build" }
end.start
sleep
end
rescue Interrupt
warn "SIGINT: exit"
2023-11-27 22:18:10 +01:00
exit
2023-07-25 20:32:57 +02:00
end
end