blob: 726749bb5a83f59d948f0853bea13c4b344cb54f [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",
Alex Perryb3168082022-01-22 13:36:13 -080024 "@npm//@angular/animations",
25 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080026 "@npm//@angular/core",
27 "@npm//@angular/platform-browser",
28 ],
29)
30
31rollup_bundle(
32 name = "main_bundle",
33 entry_point = "main.ts",
34 deps = [
35 "app",
36 ],
37)
38
39babel(
40 name = "main_bundle_compiled",
41 args = [
Alex Perrya96eb6a2022-04-02 17:05:17 -070042 "$(execpath :main_bundle.min.js)",
Alex Perryb3168082022-01-22 13:36:13 -080043 "--no-babelrc",
44 "--source-maps",
Alex Perry7ed62bf2022-04-02 13:33:58 -070045 "--minified",
46 "--no-comments",
Alex Perryb3168082022-01-22 13:36:13 -080047 "--plugins=@angular/compiler-cli/linker/babel",
48 "--out-dir",
49 "$(@D)",
50 ],
51 data = [
Alex Perrya96eb6a2022-04-02 17:05:17 -070052 ":main_bundle.min.js",
Alex Perryb3168082022-01-22 13:36:13 -080053 "@npm//@angular/compiler-cli",
54 ],
55 output_dir = True,
Philipp Schraderbc38b4e2022-04-02 15:47:23 -070056)
57
58# The babel() rule above puts everything into a directory without telling bazel
59# what's in the directory. That makes it annoying to work with from other
60# rules. This genrule() here copies the one file in the directory we care about
61# so that other rules have an easier time using the file.
62genrule(
63 name = "main_bundle_file",
64 srcs = [":main_bundle_compiled"],
65 outs = ["main_bundle_file.js"],
Alex Perrya96eb6a2022-04-02 17:05:17 -070066 cmd = "cp $(location :main_bundle_compiled)/main_bundle.min.js $(OUTS)",
Philipp Schrader684a8e82022-02-25 17:39:28 -080067)
68
69# Create a copy of zone.js here so that we can have a predictable path to
70# source it from on the webserver.
71genrule(
72 name = "zonejs_copy",
73 srcs = [
74 "@npm//:node_modules/zone.js/dist/zone.min.js",
75 ],
76 outs = [
77 "npm/node_modules/zone.js/dist/zone.min.js",
78 ],
79 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -070080)
81
82genrule(
83 name = "field_pictures_copy",
84 srcs = ["//third_party/y2022/field:pictures"],
85 outs = [
86 "pictures/field/balls.jpeg",
87 "pictures/field/quadrants.jpeg",
88 ],
89 cmd = "cp $(SRCS) $(@D)/pictures/field/",
90)
91
92filegroup(
93 name = "static_files",
94 srcs = [
95 "index.html",
96 ":field_pictures_copy",
Philipp Schraderbc38b4e2022-04-02 15:47:23 -070097 ":main_bundle_file.js",
Philipp Schrader577befe2022-03-15 00:00:49 -070098 ":zonejs_copy",
99 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -0800100 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -0800101)
102
Philipp Schrader72beced2022-03-07 05:29:52 -0800103filegroup(
104 name = "common_css",
105 srcs = ["common.css"],
106 visibility = ["//scouting/www:__subpackages__"],
107)