databuild/databuild/dashboard/BUILD.bazel
soaxelbrooke 5af7e751ae
Some checks are pending
/ setup (push) Waiting to run
Fetch from the actual service
2025-07-12 09:59:27 -07:00

119 lines
3 KiB
Python

load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@npm//:defs.bzl", "npm_link_all_packages")
npm_link_all_packages(name = "node_modules")
filegroup(
name = "dist",
srcs = [
# To be added once we have one
# "favicon.svg",
"index.html",
":app_dist",
":css",
],
visibility = ["//visibility:public"],
)
genrule(
name = "css",
srcs = [
"index.css",
"index.html",
":node_modules/daisyui",
":app_dist",
],
outs = ["dist.css"],
cmd = """
# Must manually copy sources, because tailwind silently ignores symlinked files:
# https://github.com/tailwindlabs/tailwindcss/issues/13731
WORKDIR=$$(dirname $(location index.css))
find $$WORKDIR -type l -exec bash -c 'echo "> $${0}" && cp -fL "$${0}" "$${0}.tmp" && mv "$${0}.tmp" "$${0}"' {} \\;
# Copy over source from built TS app so that tailwind can see the used classes
for fpath in $(locations :app_dist); do
cp $$fpath $$WORKDIR
done
# Include daisyui plugin
cp -R $(@D)/node_modules/.aspect_rules_js/*/node_modules $$WORKDIR/node_modules
# Run tailwind build
$(location //tools/build_rules:tailwind) -i $(location index.css) -o $@
""",
tools = ["//tools/build_rules:tailwind"],
)
ts_config(
name = "ts_config_app",
src = ":tsconfig_app.json",
visibility = ["//visibility:public"],
)
ts_config(
name = "ts_config_test",
src = ":tsconfig_test.json",
visibility = ["//visibility:public"],
)
# Making modules of ts projects seems to be a rats nest.
# Hopefully we can figure this out in the future.
ts_project(
name = "app",
srcs = [
"index.ts",
"layout.ts",
"pages.ts",
"services.ts",
"utils.ts",
],
allow_js = True,
resolve_json_module = True,
transpiler = "tsc",
tsconfig = ":ts_config_app",
deps = [
":node_modules/@types/mithril",
":node_modules/@types/node",
":node_modules/mithril",
":node_modules/whatwg-fetch",
"//databuild/client:typescript_lib",
],
)
esbuild(
name = "app_dist",
srcs = [":app"],
bazel_sandbox_plugin = True,
entry_point = "index.js",
# esbuild_log_level = "verbose",
# js_log_level = "debug",
metafile = True,
visibility = ["//visibility:public"],
)
ts_project(
name = "test_app",
testonly = True,
srcs = [
"index.test.ts",
"utils.test.ts",
],
allow_js = True,
resolve_json_module = True,
transpiler = "tsc",
tsconfig = ":ts_config_test",
deps = [
":app",
":node_modules/@types/mithril",
":node_modules/@types/node",
":node_modules/@types/ospec",
":node_modules/mithril",
":node_modules/ospec",
],
)
js_test(
name = "app_test",
chdir = package_name(),
data = [":test_app"],
entry_point = "index.test.js",
)