frontend: add rake tasks, improve performance in 'watch' mode

This commit is contained in:
0x1eef 2024-01-13 22:50:37 -03:00
parent d4604b8a6e
commit 9cfab64412
4 changed files with 29 additions and 0 deletions

View file

@ -6,3 +6,11 @@ gem "nanoc-live", "~> 1.0"
gem "nanoc-webpack.rb", "~> 0.5"
gem "sass", "~> 3.7"
gem "rainpress", "~> 1.0"
require 'rbconfig'
case RbConfig::CONFIG['target_os']
when /(?i-mx:bsd|dragonfly)/
gem 'rb-kqueue', '>= 0.2'
else
# Poll
end

View file

@ -94,6 +94,8 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rb-kqueue (0.2.8)
ffi (>= 0.5.0)
rbtree (0.4.6)
ryo.rb (0.4.5)
sass (3.7.4)
@ -126,6 +128,7 @@ DEPENDENCIES
nanoc-webpack.rb (~> 0.5)
rainpress (~> 1.0)
rake (~> 13.0)
rb-kqueue (>= 0.2)
sass (~> 3.7)
twenty-frontend!

View file

@ -1,4 +1,5 @@
require "bundler/setup"
load 'tasks/nanoc.rake'
namespace :schema do
desc "Generate src/js/types/schema.ts"
task :regen do

View file

@ -0,0 +1,17 @@
namespace :nanoc do
desc "Produce the build/ directory"
task :build do
sh "nanoc co"
end
desc "Produce the build/ directory on-demand"
task watch: ['nanoc:build'] do
require "listen"
path = File.join(Dir.getwd, "src")
Listen.to(path) { sh "rake nanoc:build" }.start
sleep
rescue Interrupt
warn "SIGINT: exit"
exit
end
end