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.
This commit is contained in:
@@ -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)"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user