blob: 3b473f1fdff87b72d91be3ba64273ae57613161b [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 Perrybb901052022-03-23 19:46:15 -070023 "//scouting/www/notes",
Milo Lin26b2cbb2022-03-26 17:35:20 -070024 "//scouting/www/shift_schedule",
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 = [
43 "$(execpath :main_bundle)",
44 "--no-babelrc",
45 "--source-maps",
46 "--plugins=@angular/compiler-cli/linker/babel",
47 "--out-dir",
48 "$(@D)",
49 ],
50 data = [
51 ":main_bundle",
52 "@npm//@angular/compiler-cli",
53 ],
54 output_dir = True,
Philipp Schrader684a8e82022-02-25 17:39:28 -080055 visibility = ["//visibility:public"],
56)
57
58# Create a copy of zone.js here so that we can have a predictable path to
59# source it from on the webserver.
60genrule(
61 name = "zonejs_copy",
62 srcs = [
63 "@npm//:node_modules/zone.js/dist/zone.min.js",
64 ],
65 outs = [
66 "npm/node_modules/zone.js/dist/zone.min.js",
67 ],
68 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -070069)
70
71genrule(
72 name = "field_pictures_copy",
73 srcs = ["//third_party/y2022/field:pictures"],
74 outs = [
75 "pictures/field/balls.jpeg",
76 "pictures/field/quadrants.jpeg",
77 ],
78 cmd = "cp $(SRCS) $(@D)/pictures/field/",
79)
80
81filegroup(
82 name = "static_files",
83 srcs = [
84 "index.html",
85 ":field_pictures_copy",
86 ":zonejs_copy",
87 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -080088 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080089)
90
91concatjs_devserver(
92 name = "devserver",
93 serving_path = "/main_bundle.js",
94 static_files = [
Philipp Schrader577befe2022-03-15 00:00:49 -070095 ":static_files",
Alex Perryb3168082022-01-22 13:36:13 -080096 ],
97 deps = [":main_bundle_compiled"],
98)
Philipp Schrader72beced2022-03-07 05:29:52 -080099
100filegroup(
101 name = "common_css",
102 srcs = ["common.css"],
103 visibility = ["//scouting/www:__subpackages__"],
104)