blob: 39246d8130ef99a5547dfac7f5c69e800e77434c [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",
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)",
69 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080070)
71
72concatjs_devserver(
73 name = "devserver",
74 serving_path = "/main_bundle.js",
75 static_files = [
Philipp Schrader684a8e82022-02-25 17:39:28 -080076 "index.html",
77 ":zonejs_copy",
Alex Perryb3168082022-01-22 13:36:13 -080078 ],
79 deps = [":main_bundle_compiled"],
80)