dolphins7.skeleton/client/nanoc/rules/react.rules
2024-04-25 12:51:19 -03:00

23 lines
710 B
Ruby

#!/usr/bin/env ruby
# frozen_string_literal: true
{
"Task" => ["tasks/new", "tasks/edit"],
"Tasks" => ["/", "tasks"],
"Projects" => ["projects"]
}.each do |component, paths|
compile "/html/react.html.erb", rep: component do
filter(:erb, locals: {component: "react-#{component.downcase}", src: "/js/main.js"})
paths.each do |path|
(path == "/") ? write("/index.html") : write("/#{path}/index.html")
end
end
end
compile "/js/main/main.tsx" do
buildenv = ENV["buildenv"] || "development"
filter(:webpack,
argv: ["--mode", buildenv, "--config", "webpack.#{buildenv}.js"],
depend_on: %w[/js/components/ /js/hooks/ /js/types/ /js/lib/])
write("/js/main.js")
end