Philipp Schrader | 5404796 | 2022-02-16 21:05:11 -0800 | [diff] [blame] | 1 | load("@npm//@bazel/typescript:index.bzl", "ts_library") |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 2 | load("//tools/build_rules:js.bzl", "rollup_bundle") |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 3 | load("@npm//@babel/cli:index.bzl", "babel") |
| 4 | |
Philipp Schrader | 5404796 | 2022-02-16 21:05:11 -0800 | [diff] [blame] | 5 | ts_library( |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 6 | name = "app", |
| 7 | srcs = glob([ |
| 8 | "*.ts", |
Philipp Schrader | 5404796 | 2022-02-16 21:05:11 -0800 | [diff] [blame] | 9 | ]), |
| 10 | angular_assets = glob([ |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 11 | "*.ng.html", |
Philipp Schrader | 8058743 | 2022-03-05 15:41:22 -0800 | [diff] [blame] | 12 | "*.css", |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 13 | ]), |
Philipp Schrader | 5404796 | 2022-02-16 21:05:11 -0800 | [diff] [blame] | 14 | compiler = "//tools:tsc_wrapped_with_angular", |
| 15 | target_compatible_with = ["@platforms//cpu:x86_64"], |
| 16 | use_angular_plugin = True, |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 17 | visibility = ["//visibility:public"], |
| 18 | deps = [ |
Filip Kujawa | 210a03b | 2022-11-24 14:41:11 -0800 | [diff] [blame] | 19 | "//scouting/www/driver_ranking", |
Philipp Schrader | 8058743 | 2022-03-05 15:41:22 -0800 | [diff] [blame] | 20 | "//scouting/www/entry", |
Philipp Schrader | 72beced | 2022-03-07 05:29:52 -0800 | [diff] [blame] | 21 | "//scouting/www/import_match_list", |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 22 | "//scouting/www/match_list", |
Alex Perry | bb90105 | 2022-03-23 19:46:15 -0700 | [diff] [blame] | 23 | "//scouting/www/notes", |
Milo Lin | 26b2cbb | 2022-03-26 17:35:20 -0700 | [diff] [blame] | 24 | "//scouting/www/shift_schedule", |
Ishan Katpally | dad5f1a | 2022-03-23 21:06:36 -0700 | [diff] [blame] | 25 | "//scouting/www/view", |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 26 | "@npm//@angular/animations", |
| 27 | "@npm//@angular/common", |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 28 | "@npm//@angular/core", |
| 29 | "@npm//@angular/platform-browser", |
| 30 | ], |
| 31 | ) |
| 32 | |
| 33 | rollup_bundle( |
| 34 | name = "main_bundle", |
| 35 | entry_point = "main.ts", |
| 36 | deps = [ |
| 37 | "app", |
| 38 | ], |
| 39 | ) |
| 40 | |
| 41 | babel( |
| 42 | name = "main_bundle_compiled", |
| 43 | args = [ |
Alex Perry | a96eb6a | 2022-04-02 17:05:17 -0700 | [diff] [blame] | 44 | "$(execpath :main_bundle.min.js)", |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 45 | "--no-babelrc", |
| 46 | "--source-maps", |
Alex Perry | 7ed62bf | 2022-04-02 13:33:58 -0700 | [diff] [blame] | 47 | "--minified", |
| 48 | "--no-comments", |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 49 | "--plugins=@angular/compiler-cli/linker/babel", |
| 50 | "--out-dir", |
| 51 | "$(@D)", |
| 52 | ], |
| 53 | data = [ |
Alex Perry | a96eb6a | 2022-04-02 17:05:17 -0700 | [diff] [blame] | 54 | ":main_bundle.min.js", |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 55 | "@npm//@angular/compiler-cli", |
| 56 | ], |
| 57 | output_dir = True, |
Philipp Schrader | bc38b4e | 2022-04-02 15:47:23 -0700 | [diff] [blame] | 58 | ) |
| 59 | |
| 60 | # The babel() rule above puts everything into a directory without telling bazel |
| 61 | # what's in the directory. That makes it annoying to work with from other |
| 62 | # rules. This genrule() here copies the one file in the directory we care about |
| 63 | # so that other rules have an easier time using the file. |
| 64 | genrule( |
| 65 | name = "main_bundle_file", |
| 66 | srcs = [":main_bundle_compiled"], |
| 67 | outs = ["main_bundle_file.js"], |
Alex Perry | a96eb6a | 2022-04-02 17:05:17 -0700 | [diff] [blame] | 68 | cmd = "cp $(location :main_bundle_compiled)/main_bundle.min.js $(OUTS)", |
Philipp Schrader | 684a8e8 | 2022-02-25 17:39:28 -0800 | [diff] [blame] | 69 | ) |
| 70 | |
Philipp Schrader | 45721a7 | 2022-04-02 16:27:53 -0700 | [diff] [blame] | 71 | py_binary( |
| 72 | name = "index_html_generator", |
| 73 | srcs = ["index_html_generator.py"], |
| 74 | ) |
| 75 | |
| 76 | genrule( |
| 77 | name = "generate_index_html", |
| 78 | srcs = [ |
| 79 | "index.template.html", |
| 80 | "main_bundle_file.js", |
| 81 | ], |
| 82 | outs = ["index.html"], |
| 83 | cmd = " ".join([ |
| 84 | "$(location :index_html_generator)", |
| 85 | "--template $(location index.template.html)", |
| 86 | "--bundle $(location main_bundle_file.js)", |
| 87 | "--output $(location index.html)", |
| 88 | ]), |
| 89 | tools = [ |
| 90 | ":index_html_generator", |
| 91 | ], |
| 92 | ) |
| 93 | |
Philipp Schrader | 684a8e8 | 2022-02-25 17:39:28 -0800 | [diff] [blame] | 94 | # Create a copy of zone.js here so that we can have a predictable path to |
| 95 | # source it from on the webserver. |
| 96 | genrule( |
| 97 | name = "zonejs_copy", |
| 98 | srcs = [ |
| 99 | "@npm//:node_modules/zone.js/dist/zone.min.js", |
| 100 | ], |
| 101 | outs = [ |
| 102 | "npm/node_modules/zone.js/dist/zone.min.js", |
| 103 | ], |
| 104 | cmd = "cp $(SRCS) $(OUTS)", |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 105 | ) |
| 106 | |
| 107 | genrule( |
| 108 | name = "field_pictures_copy", |
| 109 | srcs = ["//third_party/y2022/field:pictures"], |
| 110 | outs = [ |
| 111 | "pictures/field/balls.jpeg", |
| 112 | "pictures/field/quadrants.jpeg", |
Emily Markova | 4b804c1 | 2022-11-02 21:30:04 -0700 | [diff] [blame] | 113 | "pictures/field/reversed_quadrants.jpeg", |
| 114 | "pictures/field/reversed_balls.jpeg", |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 115 | ], |
| 116 | cmd = "cp $(SRCS) $(@D)/pictures/field/", |
| 117 | ) |
| 118 | |
| 119 | filegroup( |
| 120 | name = "static_files", |
| 121 | srcs = [ |
| 122 | "index.html", |
| 123 | ":field_pictures_copy", |
Philipp Schrader | bc38b4e | 2022-04-02 15:47:23 -0700 | [diff] [blame] | 124 | ":main_bundle_file.js", |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 125 | ":zonejs_copy", |
| 126 | ], |
Philipp Schrader | 684a8e8 | 2022-02-25 17:39:28 -0800 | [diff] [blame] | 127 | visibility = ["//visibility:public"], |
Alex Perry | b316808 | 2022-01-22 13:36:13 -0800 | [diff] [blame] | 128 | ) |
| 129 | |
Philipp Schrader | 72beced | 2022-03-07 05:29:52 -0800 | [diff] [blame] | 130 | filegroup( |
| 131 | name = "common_css", |
| 132 | srcs = ["common.css"], |
| 133 | visibility = ["//scouting/www:__subpackages__"], |
| 134 | ) |