blob: f386f0696a748f3765a80b48f0cabafb58862b20 [file] [log] [blame]
Philipp Schrader54047962022-02-16 21:05:11 -08001load("@npm//@bazel/typescript:index.bzl", "ts_library")
Alex Perryb3168082022-01-22 13:36:13 -08002load("//tools/build_rules:js.bzl", "rollup_bundle")
3load("@npm//@bazel/concatjs:index.bzl", "concatjs_devserver")
4load("@npm//@babel/cli:index.bzl", "babel")
5
Philipp Schrader54047962022-02-16 21:05:11 -08006ts_library(
Alex Perryb3168082022-01-22 13:36:13 -08007 name = "app",
8 srcs = glob([
9 "*.ts",
Philipp Schrader54047962022-02-16 21:05:11 -080010 ]),
11 angular_assets = glob([
Alex Perryb3168082022-01-22 13:36:13 -080012 "*.ng.html",
Philipp Schrader80587432022-03-05 15:41:22 -080013 "*.css",
Alex Perryb3168082022-01-22 13:36:13 -080014 ]),
Philipp Schrader54047962022-02-16 21:05:11 -080015 compiler = "//tools:tsc_wrapped_with_angular",
16 target_compatible_with = ["@platforms//cpu:x86_64"],
17 use_angular_plugin = True,
Alex Perryb3168082022-01-22 13:36:13 -080018 visibility = ["//visibility:public"],
19 deps = [
Philipp Schrader80587432022-03-05 15:41:22 -080020 "//scouting/www/entry",
Philipp Schrader72beced2022-03-07 05:29:52 -080021 "//scouting/www/import_match_list",
Ravago Jones2813c032022-03-16 23:44:11 -070022 "//scouting/www/match_list",
Alex Perryb3168082022-01-22 13:36:13 -080023 "@npm//@angular/animations",
24 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080025 "@npm//@angular/core",
26 "@npm//@angular/platform-browser",
27 ],
28)
29
30rollup_bundle(
31 name = "main_bundle",
32 entry_point = "main.ts",
33 deps = [
34 "app",
35 ],
36)
37
38babel(
39 name = "main_bundle_compiled",
40 args = [
41 "$(execpath :main_bundle)",
42 "--no-babelrc",
43 "--source-maps",
44 "--plugins=@angular/compiler-cli/linker/babel",
45 "--out-dir",
46 "$(@D)",
47 ],
48 data = [
49 ":main_bundle",
50 "@npm//@angular/compiler-cli",
51 ],
52 output_dir = True,
Philipp Schrader684a8e82022-02-25 17:39:28 -080053 visibility = ["//visibility:public"],
54)
55
56# Create a copy of zone.js here so that we can have a predictable path to
57# source it from on the webserver.
58genrule(
59 name = "zonejs_copy",
60 srcs = [
61 "@npm//:node_modules/zone.js/dist/zone.min.js",
62 ],
63 outs = [
64 "npm/node_modules/zone.js/dist/zone.min.js",
65 ],
66 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -070067)
68
69genrule(
70 name = "field_pictures_copy",
71 srcs = ["//third_party/y2022/field:pictures"],
72 outs = [
73 "pictures/field/balls.jpeg",
74 "pictures/field/quadrants.jpeg",
75 ],
76 cmd = "cp $(SRCS) $(@D)/pictures/field/",
77)
78
79filegroup(
80 name = "static_files",
81 srcs = [
82 "index.html",
83 ":field_pictures_copy",
84 ":zonejs_copy",
85 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -080086 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080087)
88
89concatjs_devserver(
90 name = "devserver",
91 serving_path = "/main_bundle.js",
92 static_files = [
Philipp Schrader577befe2022-03-15 00:00:49 -070093 ":static_files",
Alex Perryb3168082022-01-22 13:36:13 -080094 ],
95 deps = [":main_bundle_compiled"],
96)
Philipp Schrader72beced2022-03-07 05:29:52 -080097
98filegroup(
99 name = "common_css",
100 srcs = ["common.css"],
101 visibility = ["//scouting/www:__subpackages__"],
102)