comparison mrjunejune/BUILD @ 241:9c2eec61a152

[assets] Generate site images as WebP with Bazel
author MrJuneJune <me@mrjunejune.com>
date Mon, 03 Aug 2026 11:26:30 -0700
parents 1de6f553cbc0
children 543df0fe7168
comparison
equal deleted inserted replaced
240:c345083cd8a7 241:9c2eec61a152
1 load("@rules_cc//cc:cc_binary.bzl", "cc_binary") 1 load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2 load("@rules_cc//cc:cc_library.bzl", "cc_library") 2 load("@rules_cc//cc:cc_library.bzl", "cc_library")
3 load("@rules_shell//shell:sh_binary.bzl", "sh_binary") 3 load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
4 load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle") 4 load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle", "webp_image")
5
6 _PNG_ASSETS = [
7 "23k",
8 "blue-noise-random",
9 "blue-noises-optimal",
10 "dog-treat",
11 "epi_all_colors",
12 "icon-192",
13 "icon-512",
14 "icon-maskable-512",
15 "logo_black",
16 "logo_white",
17 "logo_white_og",
18 "sprite_shiba0",
19 "sprite_shiba1",
20 "sprite_shiba2",
21 "sprite_shiba3",
22 "start-large",
23 "start-small-1",
24 "start-small-2",
25 "start-small-3",
26 "vscode",
27 "wabbit_alpha",
28 "white-noise-grass",
29 ]
30
31 _LOSSLESS_WEBP_ASSETS = [
32 "dog-treat",
33 "epi_all_colors",
34 "icon-192",
35 "icon-512",
36 "icon-maskable-512",
37 "logo_black",
38 "logo_white",
39 "logo_white_og",
40 "sprite_shiba0",
41 "sprite_shiba1",
42 "sprite_shiba2",
43 "sprite_shiba3",
44 "start-large",
45 "start-small-1",
46 "start-small-2",
47 "start-small-3",
48 "wabbit_alpha",
49 ]
50
51 [
52 webp_image(
53 name = "webp_{}".format(asset.replace("-", "_")),
54 src = "assets/png/{}.png".format(asset),
55 out = "generated_webp/{}.webp".format(asset),
56 lossless = asset in _LOSSLESS_WEBP_ASSETS,
57 )
58 for asset in _PNG_ASSETS
59 ]
60
61 filegroup(
62 name = "generated_webp_assets",
63 srcs = [
64 ":webp_{}".format(asset.replace("-", "_"))
65 for asset in _PNG_ASSETS
66 ],
67 )
68
69 move_files_into_dir(
70 name = "generated_public_webp",
71 srcs = [":generated_webp_assets"],
72 dest = "src/public",
73 )
5 74
6 # Files 75 # Files
7 move_files_into_dir( 76 move_files_into_dir(
8 name = "react_pages", 77 name = "react_pages",
9 srcs = [ 78 srcs = [
45 dest = "src/public/icons", 114 dest = "src/public/icons",
46 ) 115 )
47 116
48 filegroup( 117 filegroup(
49 name = "public_files", 118 name = "public_files",
50 srcs = glob(["src/public/*"]), 119 srcs = glob(
120 ["src/public/*"],
121 exclude = ["src/public/*.png"],
122 ) + [":generated_public_webp"],
51 visibility = ["//visibility:public"], 123 visibility = ["//visibility:public"],
52 ) 124 )
53 125
54 filegroup( 126 filegroup(
55 name = "public_fonts_files", 127 name = "public_fonts_files",
57 visibility = ["//visibility:public"], 129 visibility = ["//visibility:public"],
58 ) 130 )
59 131
60 filegroup( 132 filegroup(
61 name = "src_files", 133 name = "src_files",
62 srcs = glob(["src/**"]) + [":react_pages", ":shared_js_non_public", ":shared_js_file", ":rich_editor_js", ":icons"], 134 srcs = glob(
135 ["src/**"],
136 exclude = ["src/**/*.png"],
137 ) + [":react_pages", ":shared_js_non_public", ":shared_js_file", ":rich_editor_js", ":icons", ":generated_public_webp"],
63 visibility = ["//mrjunejune/test:__pkg__"], 138 visibility = ["//mrjunejune/test:__pkg__"],
64 ) 139 )
65 140
66 # Server binary 141 # Server binary
67 cc_binary( 142 cc_binary(