From 57e00aa4b4b10851c3e780e27be635c1eada2330 Mon Sep 17 00:00:00 2001 From: zhangxiang Date: Tue, 18 Aug 2026 13:03:58 +0800 Subject: [PATCH] fix(deploy): serve standalone client chunks at /_next/static Next.js standalone output places client chunks under dist/static, but the generated HTML references /_next/static/... which Nginx serves from dist/_next/static. Mirror static -> _next/static during build so CSS/JS load with correct MIME types instead of 404. --- scripts/deploy.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index eb937c7..2b890cb 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -144,6 +144,14 @@ cmd_build() { log "✅ public 静态资源已同步到 $DIST_DIR" fi + # standalone 构建的客户端静态资源位于 dist/static,而 HTML 引用 /_next/static/...; + # 复制到 dist/_next/static 供 Nginx 直接服务 + if [[ -d "$DIST_DIR/static" ]]; then + mkdir -p "$DIST_DIR/_next" + cp -R "$DIST_DIR/static" "$DIST_DIR/_next/static" + log "✅ _next/static 已从 static 同步到 $DIST_DIR/_next/static" + fi + log "✅ 构建完成,产物大小: $(du -sh "$DIST_DIR" | cut -f1)" }