fix: 前端生产构建放宽node堆内存并跳过basicSsl避免服务器卡死

This commit is contained in:
2026-09-02 10:39:05 +08:00
parent 06337fc8eb
commit fe495ad707
2 changed files with 9 additions and 1 deletions

View File

@ -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 . .

View File

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