From fe495ad707832fe6c0b23c72f10998b60ceeac9c Mon Sep 17 00:00:00 2001 From: duxingchen Date: Wed, 2 Sep 2026 10:39:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=94=BE=E5=AE=BDnode=E5=A0=86=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=B9=B6=E8=B7=B3=E8=BF=87basicSsl=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/Dockerfile.prod | 2 ++ frontend/vite.config.ts | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/Dockerfile.prod b/frontend/Dockerfile.prod index b1c7e32..731f5a6 100644 --- a/frontend/Dockerfile.prod +++ b/frontend/Dockerfile.prod @@ -5,6 +5,8 @@ # --- 阶段 1:编译 React --- FROM node:20-alpine AS builder WORKDIR /app +# 🚀 构建内存优化:显式放宽 node 堆上限,避免低配服务器 OOM 挂起(卡在 vite build) +ENV NODE_OPTIONS="--max-old-space-size=4096" COPY package.json package-lock.json ./ RUN npm ci --production=false COPY . . diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 8670487..a51ccb8 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -5,7 +5,13 @@ import basicSsl from "@vitejs/plugin-basic-ssl"; // https://vite.dev/config/ export default defineConfig({ - plugins: [react(), tailwindcss(), basicSsl()], + // 🚀 basicSsl 仅 dev(本地 HMR https)需要;生产 build 跳过, + // 避免服务器容器低熵环境下生成自签名证书导致 vite build 卡住 + plugins: [ + react(), + tailwindcss(), + ...(process.env.NODE_ENV !== "production" ? [basicSsl()] : []), + ], // 🚀 构建优化:将第三方巨头独立分包,利用浏览器缓存 build: {