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