dolphins7.skeleton/twenty-frontend/tasks/nanoc.rake

37 lines
876 B
Ruby

namespace :nanoc do
require "bundler/setup"
cwd = File.realpath File.join(__dir__, "..")
desc "Clean the build/ directory"
task :clean do
Dir.chdir(cwd) do
sh "rm -rf node_modules/.cache/"
sh "rm -rf build"
end
end
desc "Produce the build/ directory"
task :build do
Dir.chdir(cwd) do
# FIXME: discover why rm -rf build/css/ is needed.
ENV["NODE_ENV"] = "production"
sh "rm -rf build/css/"
Bundler.with_unbundled_env { sh "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"
exit
end
end