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: {