blob: aa2ad7b7b9038e1c0aebe56eb4566b28e5c6259b [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",
17 ]),
Philipp Schrader54047962022-02-16 21:05:11 -080018 compiler = "//tools:tsc_wrapped_with_angular",
19 target_compatible_with = ["@platforms//cpu:x86_64"],
20 use_angular_plugin = True,
Alex Perryb3168082022-01-22 13:36:13 -080021 visibility = ["//visibility:public"],
22 deps = [
23 "@npm//@angular/animations",
24 "@npm//@angular/common",
Alex Perryb3168082022-01-22 13:36:13 -080025 "@npm//@angular/core",
26 "@npm//@angular/platform-browser",
27 ],
28)
29
30rollup_bundle(
31 name = "main_bundle",
32 entry_point = "main.ts",
33 deps = [
34 "app",
35 ],
36)
37
38babel(
39 name = "main_bundle_compiled",
40 args = [
41 "$(execpath :main_bundle)",
42 "--no-babelrc",
43 "--source-maps",
44 "--plugins=@angular/compiler-cli/linker/babel",
45 "--out-dir",
46 "$(@D)",
47 ],
48 data = [
49 ":main_bundle",
50 "@npm//@angular/compiler-cli",
51 ],
52 output_dir = True,
Philipp Schrader684a8e82022-02-25 17:39:28 -080053 visibility = ["//visibility:public"],
54)
55
56# Create a copy of zone.js here so that we can have a predictable path to
57# source it from on the webserver.
58genrule(
59 name = "zonejs_copy",
60 srcs = [
61 "@npm//:node_modules/zone.js/dist/zone.min.js",
62 ],
63 outs = [
64 "npm/node_modules/zone.js/dist/zone.min.js",
65 ],
66 cmd = "cp $(SRCS) $(OUTS)",
67 visibility = ["//visibility:public"],
Alex Perryb3168082022-01-22 13:36:13 -080068)
69
70concatjs_devserver(
71 name = "devserver",
72 serving_path = "/main_bundle.js",
73 static_files = [
Philipp Schrader684a8e82022-02-25 17:39:28 -080074 "index.html",
75 ":zonejs_copy",
Alex Perryb3168082022-01-22 13:36:13 -080076 ],
77 deps = [":main_bundle_compiled"],
78)