al-quran_kaios/Rules

53 lines
1.3 KiB
Ruby

#!/usr/bin/env ruby
# frozen_string_literal: true
##
# Requires
require "ryo"
require "ryo/json"
require "ryo/yaml"
require "nanoc-webpack"
##
# Extensions
[Nanoc::RuleDSL::CompilationRuleContext, Nanoc::RuleDSL::CompilerDSL].each { _1.prepend(Utils) }
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::Extension::AnonymousFilter)
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::Extension::RequireRules)
##
# Locals
locales = %w[ar fa en]
name_by_id = Ryo.from_json(path: File.join(dirs.content, "json", "nameById.json"))
tdata = Ryo.from_json(path: File.join(dirs.content, "json", "t.json"))
surahs = Ryo.from_json(path: File.join(dirs.content, "json", "surahs.json"))
tidy = `which tidy || which tidy5`.chomp
buildenv = ENV["buildenv"] || "development"
##
# Rules
passthrough "/json/**/*.json"
require_rules "nanoc/rules/assets"
compile "/js/vendor.ts" do
filter :webpack,
argv: %w[--config etc/webpack.vendor.js]
write("/js/vendor.js")
end
compile("/js/index.tsx") do
filter :webpack,
argv: ["--config", "etc/webpack.#{buildenv}.js"],
depend_on: ["/js/components", "/js/lib", "/js/hooks", "/css"]
write("/js/index.js")
end
compile("/html/index.html") do
write("/index.html")
end
compile("/manifest.webapp") do
write("/manifest.webapp")
end
compile("/**/*") { write(nil) }
layout("**/*", :erb)