blob: 675a4fbdea05eef5371d8c7b78f493700539b955 [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",
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 = [
52 ":main_bundle",
53 "@npm//@angular/compiler-cli",
54 ],
55 output_dir = True,
Philipp Schrader684a8e82022-02-25 17:39:28 -080056 visibility = ["//visibility:public"],
57)
58
59# Create a copy of zone.js here so that we can have a predictable path to
60# source it from on the webserver.
61genrule(
62 name = "zonejs_copy",
63 srcs = [
64 "@npm//:node_modules/zone.js/dist/zone.min.js",
65 ],
66 outs = [
67 "npm/node_modules/zone.js/dist/zone.min.js",
68 ],
69 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -070070)
71
72genrule(
73 name = "field_pictures_copy",
74 srcs = ["//third_party/y2022/field:pictures"],
75 outs = [
76 "pictures/field/balls.jpeg",
77 "pictures/field/quadrants.jpeg",
78 ],
79 cmd = "cp $(SRCS) $(@D)/pictures/field/",
80)
81
82filegroup(
83 name = "static_files",
84 srcs = [
85 "index.html",
86 ":field_pictures_copy",
87 ":zonejs_copy",
88 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -080089 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080090)
91
92concatjs_devserver(
93 name = "devserver",
94 serving_path = "/main_bundle.js",
95 static_files = [
Philipp Schrader577befe2022-03-15 00:00:49 -070096 ":static_files",
Alex Perryb3168082022-01-22 13:36:13 -080097 ],
98 deps = [":main_bundle_compiled"],
99)
Philipp Schrader72beced2022-03-07 05:29:52 -0800100
101filegroup(
102 name = "common_css",
103 srcs = ["common.css"],
104 visibility = ["//scouting/www:__subpackages__"],
105)