diff --git a/README.md b/README.md index 338934b..a7cfb41 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

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),  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 diff --git a/Rakefile.rb b/Rakefile.rb index 8b6aa3d..29b00d4 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -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"