Add 'rake build:watch'

This commit is contained in:
0x1eef 2023-07-08 22:30:39 -03:00
parent dd4e76b3f9
commit 88b92aaef0
2 changed files with 16 additions and 3 deletions

View file

@ -3,7 +3,7 @@
</p>
This repository contains the source code of
[al-quran.reflectslight.io](https://al-quran.reflectslight.io),
[al-quran.reflectslight.io](https://al-quran.reflectslight.io),&nbsp;
a static website for reading The Quran. After the
website is built, the build directory consists
of HTML, CSS, JavaScript and other static assets
@ -34,8 +34,12 @@ __2. Install Ruby, and NodeJS packages__
__3. Build website__
# Build once
rake build
# Build whenever a change is detected
rake build:watch
__4. Start server on localhost__
rake server

View file

@ -7,21 +7,30 @@ require "yaml"
build_dir = Ryo.from(YAML.load_file("./nanoc.yaml")).output_dir
namespace :nanoc do
desc "Compile the website"
task :compile do
ENV["SASS_PATH"] = "./src/css/"
sh "bundle exec nanoc co"
end
desc "Delete the build directory"
task :clean do
sh "rm -rf #{build_dir}"
end
task watch: [:compile] do
require "listen"
Listen.to File.join(Dir.getwd, "src"), force_polling: true do
sh "rake build"
end.start
sleep
end
end
desc "Build the website"
task build: "nanoc:compile"
desc "Trigger a build when src/ is modified"
task "build:watch" => "nanoc:watch"
desc "Clean the build directory"
task clean: "nanoc:clean"