blob: ee0659b697d32f659c6d06434a2941d203e968c7 [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")
Alex Perryb3168082022-01-22 13:36:13 -08003load("@npm//@babel/cli:index.bzl", "babel")
4
Philipp Schrader54047962022-02-16 21:05:11 -08005ts_library(
Alex Perryb3168082022-01-22 13:36:13 -08006 name = "app",
7 srcs = glob([
8 "*.ts",
Philipp Schrader54047962022-02-16 21:05:11 -08009 ]),
10 angular_assets = glob([
Alex Perryb3168082022-01-22 13:36:13 -080011 "*.ng.html",
Philipp Schrader80587432022-03-05 15:41:22 -080012 "*.css",
Alex Perryb3168082022-01-22 13:36:13 -080013 ]),
Philipp Schrader54047962022-02-16 21:05:11 -080014 compiler = "//tools:tsc_wrapped_with_angular",
15 target_compatible_with = ["@platforms//cpu:x86_64"],
16 use_angular_plugin = True,
Alex Perryb3168082022-01-22 13:36:13 -080017 visibility = ["//visibility:public"],
18 deps = [
Filip Kujawa210a03b2022-11-24 14:41:11 -080019 "//scouting/www/driver_ranking",
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 Perrybb901052022-03-23 19:46:15 -070023 "//scouting/www/notes",
Milo Lin26b2cbb2022-03-26 17:35:20 -070024 "//scouting/www/shift_schedule",
Ishan Katpallydad5f1a2022-03-23 21:06:36 -070025 "//scouting/www/view",
Alex Perryb3168082022-01-22 13:36:13 -080026 "@npm//@angular/animations",
27 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080028 "@npm//@angular/core",
29 "@npm//@angular/platform-browser",
30 ],
31)
32
33rollup_bundle(
34 name = "main_bundle",
35 entry_point = "main.ts",
36 deps = [
37 "app",
38 ],
39)
40
41babel(
42 name = "main_bundle_compiled",
43 args = [
Alex Perrya96eb6a2022-04-02 17:05:17 -070044 "$(execpath :main_bundle.min.js)",
Alex Perryb3168082022-01-22 13:36:13 -080045 "--no-babelrc",
46 "--source-maps",
Alex Perry7ed62bf2022-04-02 13:33:58 -070047 "--minified",
48 "--no-comments",
Alex Perryb3168082022-01-22 13:36:13 -080049 "--plugins=@angular/compiler-cli/linker/babel",
50 "--out-dir",
51 "$(@D)",
52 ],
53 data = [
Alex Perrya96eb6a2022-04-02 17:05:17 -070054 ":main_bundle.min.js",
Alex Perryb3168082022-01-22 13:36:13 -080055 "@npm//@angular/compiler-cli",
56 ],
57 output_dir = True,
Philipp Schraderbc38b4e2022-04-02 15:47:23 -070058)
59
60# The babel() rule above puts everything into a directory without telling bazel
61# what's in the directory. That makes it annoying to work with from other
62# rules. This genrule() here copies the one file in the directory we care about
63# so that other rules have an easier time using the file.
64genrule(
65 name = "main_bundle_file",
66 srcs = [":main_bundle_compiled"],
67 outs = ["main_bundle_file.js"],
Alex Perrya96eb6a2022-04-02 17:05:17 -070068 cmd = "cp $(location :main_bundle_compiled)/main_bundle.min.js $(OUTS)",
Philipp Schrader684a8e82022-02-25 17:39:28 -080069)
70
Philipp Schrader45721a72022-04-02 16:27:53 -070071py_binary(
72 name = "index_html_generator",
73 srcs = ["index_html_generator.py"],
74)
75
76genrule(
77 name = "generate_index_html",
78 srcs = [
79 "index.template.html",
80 "main_bundle_file.js",
81 ],
82 outs = ["index.html"],
83 cmd = " ".join([
84 "$(location :index_html_generator)",
85 "--template $(location index.template.html)",
86 "--bundle $(location main_bundle_file.js)",
87 "--output $(location index.html)",
88 ]),
89 tools = [
90 ":index_html_generator",
91 ],
92)
93
Philipp Schrader684a8e82022-02-25 17:39:28 -080094# Create a copy of zone.js here so that we can have a predictable path to
95# source it from on the webserver.
96genrule(
97 name = "zonejs_copy",
98 srcs = [
99 "@npm//:node_modules/zone.js/dist/zone.min.js",
100 ],
101 outs = [
102 "npm/node_modules/zone.js/dist/zone.min.js",
103 ],
104 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -0700105)
106
107genrule(
108 name = "field_pictures_copy",
109 srcs = ["//third_party/y2022/field:pictures"],
110 outs = [
111 "pictures/field/balls.jpeg",
112 "pictures/field/quadrants.jpeg",
Emily Markova4b804c12022-11-02 21:30:04 -0700113 "pictures/field/reversed_quadrants.jpeg",
114 "pictures/field/reversed_balls.jpeg",
Philipp Schrader577befe2022-03-15 00:00:49 -0700115 ],
116 cmd = "cp $(SRCS) $(@D)/pictures/field/",
117)
118
119filegroup(
120 name = "static_files",
121 srcs = [
122 "index.html",
123 ":field_pictures_copy",
Philipp Schraderbc38b4e2022-04-02 15:47:23 -0700124 ":main_bundle_file.js",
Philipp Schrader577befe2022-03-15 00:00:49 -0700125 ":zonejs_copy",
126 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -0800127 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -0800128)
129
Philipp Schrader72beced2022-03-07 05:29:52 -0800130filegroup(
131 name = "common_css",
132 srcs = ["common.css"],
133 visibility = ["//scouting/www:__subpackages__"],
134)