blob: f0b91f63e40aca0d390a698e159510cca6a3383d [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",
Alex Perryb3168082022-01-22 13:36:13 -080022 "@npm//@angular/animations",
23 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080024 "@npm//@angular/core",
25 "@npm//@angular/platform-browser",
26 ],
27)
28
29rollup_bundle(
30 name = "main_bundle",
31 entry_point = "main.ts",
32 deps = [
33 "app",
34 ],
35)
36
37babel(
38 name = "main_bundle_compiled",
39 args = [
40 "$(execpath :main_bundle)",
41 "--no-babelrc",
42 "--source-maps",
43 "--plugins=@angular/compiler-cli/linker/babel",
44 "--out-dir",
45 "$(@D)",
46 ],
47 data = [
48 ":main_bundle",
49 "@npm//@angular/compiler-cli",
50 ],
51 output_dir = True,
Philipp Schrader684a8e82022-02-25 17:39:28 -080052 visibility = ["//visibility:public"],
53)
54
55# Create a copy of zone.js here so that we can have a predictable path to
56# source it from on the webserver.
57genrule(
58 name = "zonejs_copy",
59 srcs = [
60 "@npm//:node_modules/zone.js/dist/zone.min.js",
61 ],
62 outs = [
63 "npm/node_modules/zone.js/dist/zone.min.js",
64 ],
65 cmd = "cp $(SRCS) $(OUTS)",
Philipp Schrader577befe2022-03-15 00:00:49 -070066)
67
68genrule(
69 name = "field_pictures_copy",
70 srcs = ["//third_party/y2022/field:pictures"],
71 outs = [
72 "pictures/field/balls.jpeg",
73 "pictures/field/quadrants.jpeg",
74 ],
75 cmd = "cp $(SRCS) $(@D)/pictures/field/",
76)
77
78filegroup(
79 name = "static_files",
80 srcs = [
81 "index.html",
82 ":field_pictures_copy",
83 ":zonejs_copy",
84 ],
Philipp Schrader684a8e82022-02-25 17:39:28 -080085 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080086)
87
88concatjs_devserver(
89 name = "devserver",
90 serving_path = "/main_bundle.js",
91 static_files = [
Philipp Schrader577befe2022-03-15 00:00:49 -070092 ":static_files",
Alex Perryb3168082022-01-22 13:36:13 -080093 ],
94 deps = [":main_bundle_compiled"],
95)
Philipp Schrader72beced2022-03-07 05:29:52 -080096
97filegroup(
98 name = "common_css",
99 srcs = ["common.css"],
100 visibility = ["//scouting/www:__subpackages__"],
101)