blob: b14c29b1e2775f24108ce6bd4653d533f19ac357 [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 = [
Philipp Schrader80587432022-03-05 15:41:22 -080019 "//scouting/www/entry",
Philipp Schrader72beced2022-03-07 05:29:52 -080020 "//scouting/www/import_match_list",
Ravago Jones2813c032022-03-16 23:44:11 -070021 "//scouting/www/match_list",
Alex Perrybb901052022-03-23 19:46:15 -070022 "//scouting/www/notes",
Milo Lin26b2cbb2022-03-26 17:35:20 -070023 "//scouting/www/shift_schedule",
Ishan Katpallydad5f1a2022-03-23 21:06:36 -070024 "//scouting/www/view",
Alex Perryb3168082022-01-22 13:36:13 -080025 "@npm//@angular/animations",
26 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080027 "@npm//@angular/core",
28 "@npm//@angular/platform-browser",
29 ],
30)
31
32rollup_bundle(
33 name = "main_bundle",
34 entry_point = "main.ts",
35 deps = [
36 "app",
37 ],
38)
39
40babel(
41 name = "main_bundle_compiled",
42 args = [
Alex Perrya96eb6a2022-04-02 17:05:17 -070043 "$(execpath :main_bundle.min.js)",
Alex Perryb3168082022-01-22 13:36:13 -080044 "--no-babelrc",
45 "--source-maps",
Alex Perry7ed62bf2022-04-02 13:33:58 -070046 "--minified",
47 "--no-comments",
Alex Perryb3168082022-01-22 13:36:13 -080048 "--plugins=@angular/compiler-cli/linker/babel",
49 "--out-dir",
50 "$(@D)",
51 ],
52 data = [
Alex Perrya96eb6a2022-04-02 17:05:17 -070053 ":main_bundle.min.js",
Alex Perryb3168082022-01-22 13:36:13 -080054 "@npm//@angular/compiler-cli",
55 ],
56 output_dir = True,
Philipp Schraderbc38b4e2022-04-02 15:47:23 -070057)
58
59# The babel() rule above puts everything into a directory without telling bazel
60# what's in the directory. That makes it annoying to work with from other
61# rules. This genrule() here copies the one file in the directory we care about
62# so that other rules have an easier time using the file.
63genrule(
64 name = "main_bundle_file",
65 srcs = [":main_bundle_compiled"],
66 outs = ["main_bundle_file.js"],
Alex Perrya96eb6a2022-04-02 17:05:17 -070067 cmd = "cp $(location :main_bundle_compiled)/main_bundle.min.js $(OUTS)",
Philipp Schrader684a8e82022-02-25 17:39:28 -080068)
69
Philipp Schrader45721a72022-04-02 16:27:53 -070070py_binary(
71 name = "index_html_generator",
72 srcs = ["index_html_generator.py"],
73)
74
75genrule(
76 name = "generate_index_html",
77 srcs = [
78 "index.template.html",
79 "main_bundle_file.js",
80 ],
81 outs = ["index.html"],
82 cmd = " ".join([
83 "$(location :index_html_generator)",
84 "--template $(location index.template.html)",
85 "--bundle $(location main_bundle_file.js)",
86 "--output $(location index.html)",
87 ]),
88 tools = [
89 ":index_html_generator",
90 ],
91)
92
Philipp Schrader684a8e82022-02-25 17:39:28 -080093# Create a copy of zone.js here so that we can have a predictable path to
94# source it from on the webserver.
95genrule(
96 name = "zonejs_copy",
97 srcs = [
98 "@npm//:node_modules/zone.js/dist/zone.min.js",
99 ],
100 outs = [
101 "npm/node_modules/zone.js/dist/zone.min.js",
102 ],
103 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -0700104)
105
106genrule(
107 name = "field_pictures_copy",
108 srcs = ["//third_party/y2022/field:pictures"],
109 outs = [
110 "pictures/field/balls.jpeg",
111 "pictures/field/quadrants.jpeg",
112 ],
113 cmd = "cp $(SRCS) $(@D)/pictures/field/",
114)
115
116filegroup(
117 name = "static_files",
118 srcs = [
119 "index.html",
120 ":field_pictures_copy",
Philipp Schraderbc38b4e2022-04-02 15:47:23 -0700121 ":main_bundle_file.js",
Philipp Schrader577befe2022-03-15 00:00:49 -0700122 ":zonejs_copy",
123 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -0800124 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -0800125)
126
Philipp Schrader72beced2022-03-07 05:29:52 -0800127filegroup(
128 name = "common_css",
129 srcs = ["common.css"],
130 visibility = ["//scouting/www:__subpackages__"],
131)