From fba88639a9e6516390ffed4b175fe9f9473f59a3 Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 1 Jul 2026 18:22:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20dx=20build=20=E5=90=8E=E7=94=A8?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6=E8=BF=98=E5=8E=9F=20webp=20?= =?UTF-8?q?=E4=BA=A7=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dx build 0.7.9 会把 public/ 下的 .webp 重编码成 VP8L 无损静图: 动画帧被完全丢弃(动图变静图),静图因 VP8L 无损反而膨胀 7-8 倍。 这与 Dioxus 文档承诺的「public/ 原样拷贝」不符,疑似 0.7.9 的 bug。 新增 restore-webp target:dx build 完成后遍历所有产物目录 (release/debug),用源 public/ 的同名 .webp 覆盖回去。 仅在 build / build-linux 末尾调用,build-freebsd 不受影响 (用 cargo 直出,部署直接用源 public/)。 上游修复后可移除该 target 及两处调用。 --- Makefile | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a35750f..c2a9054 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev build build-linux build-freebsd freebsd-sysroot docker css css-watch clean build-editor build-editor-incremental build-lightbox build-lightbox-incremental build-core build-core-incremental build-codemirror build-codemirror-incremental highlight-css test doc doc-open start clippy fix +.PHONY: dev build build-linux build-freebsd freebsd-sysroot docker css css-watch clean build-editor build-editor-incremental build-lightbox build-lightbox-incremental build-core build-core-incremental build-codemirror build-codemirror-incremental highlight-css test doc doc-open start clippy fix restore-webp build: @$(MAKE) build-editor @@ -9,6 +9,7 @@ build: @tailwindcss -i input.css -o public/style.css --minify @$(MAKE) doc @dx build --release --debug-symbols=false + @$(MAKE) restore-webp build-linux: @$(MAKE) build-editor @@ -19,6 +20,7 @@ build-linux: @tailwindcss -i input.css -o public/style.css --minify @dx build @client --release --debug-symbols=false --wasm-js-cfg false @dx build @server --release --debug-symbols=false --target x86_64-unknown-linux-musl --wasm-js-cfg false --features server + @$(MAKE) restore-webp @echo "" @echo "Linux build complete! The server binary is at target/dx/yggdrasil/release/web/server" @echo "Remember to deploy it alongside the target/dx/yggdrasil/release/web/public directory." @@ -61,6 +63,26 @@ build-freebsd: @echo "Deploy it to FreeBSD 15+ alongside the static public/ directory." @echo "Runtime needs (bundled in FreeBSD base): libc.so.7 libthr.so.3 libkvm.so.7 etc." +# 兜底:dx build 0.7.9 会把 public/ 下的 .webp 重编码成 VP8L 无损静图 +# (动画帧被丢弃,静图体积反增 7-8 倍),与文档承诺的"原样拷贝"不符。 +# SVG/ICO 等其他格式不受影响,故只需覆盖 .webp。 +# 遍历所有 dx 产物目录(release/debug),用源 public/ 的同名文件覆盖回去。 +# 仅覆盖产物中已存在的 .webp,不引入源里新增但 dx 未生成的文件。 +# 参考:https://dioxuslabs.com/learn/0.7/essentials/ui/assets/ +# 上游修复后可移除此 target 及 build/build-linux 里的调用。 +restore-webp: + @find target/dx -type d -path "*/web/public" 2>/dev/null | while read prod; do \ + find "$$prod" -type f -name "*.webp" 2>/dev/null | while read p; do \ + rel=$${p#$$prod/}; \ + src="public/$$rel"; \ + if [ -f "$$src" ]; then \ + cp "$$src" "$$p"; \ + else \ + echo "restore-webp: 源缺失,跳过 $$rel"; \ + fi; \ + done; \ + done + highlight-css: @cargo run --bin generate_highlight_css