blob: 8a32f898dd4bf5b44235aa4a498752cf8ebe90fc [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 Schrader684a8e82022-02-25 17:39:28 -08006exports_files([
7 "index.html",
8])
9
Philipp Schrader54047962022-02-16 21:05:11 -080010ts_library(
Alex Perryb3168082022-01-22 13:36:13 -080011 name = "app",
12 srcs = glob([
13 "*.ts",
Philipp Schrader54047962022-02-16 21:05:11 -080014 ]),
15 angular_assets = glob([
Alex Perryb3168082022-01-22 13:36:13 -080016 "*.ng.html",
Philipp Schrader80587432022-03-05 15:41:22 -080017 "*.css",
Alex Perryb3168082022-01-22 13:36:13 -080018 ]),
Philipp Schrader54047962022-02-16 21:05:11 -080019 compiler = "//tools:tsc_wrapped_with_angular",
20 target_compatible_with = ["@platforms//cpu:x86_64"],
21 use_angular_plugin = True,
Alex Perryb3168082022-01-22 13:36:13 -080022 visibility = ["//visibility:public"],
23 deps = [
Philipp Schrader80587432022-03-05 15:41:22 -080024 "//scouting/www/entry",
Philipp Schrader72beced2022-03-07 05:29:52 -080025 "//scouting/www/import_match_list",
Alex Perryb3168082022-01-22 13:36:13 -080026 "@npm//@angular/animations",
27 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080028 "@npm//@angular/core",
29 "@npm//@angular/platform-browser",
30 ],
31)
32
33rollup_bundle(
34 name = "main_bundle",
35 entry_point = "main.ts",
36 deps = [
37 "app",
38 ],
39)
40
41babel(
42 name = "main_bundle_compiled",
43 args = [
44 "$(execpath :main_bundle)",
45 "--no-babelrc",
46 "--source-maps",
47 "--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)",
70 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080071)
72
73concatjs_devserver(
74 name = "devserver",
75 serving_path = "/main_bundle.js",
76 static_files = [
Philipp Schrader684a8e82022-02-25 17:39:28 -080077 "index.html",
78 ":zonejs_copy",
Alex Perryb3168082022-01-22 13:36:13 -080079 ],
80 deps = [":main_bundle_compiled"],
81)
Philipp Schrader72beced2022-03-07 05:29:52 -080082
83filegroup(
84 name = "common_css",
85 srcs = ["common.css"],
86 visibility = ["//scouting/www:__subpackages__"],
87)