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