fix: 前端生产构建放宽node堆内存并跳过basicSsl避免服务器卡死
This commit is contained in:
@ -5,6 +5,8 @@
|
|||||||
# --- 阶段 1:编译 React ---
|
# --- 阶段 1:编译 React ---
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
# 🚀 构建内存优化:显式放宽 node 堆上限,避免低配服务器 OOM 挂起(卡在 vite build)
|
||||||
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci --production=false
|
RUN npm ci --production=false
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@ -5,7 +5,13 @@ import basicSsl from "@vitejs/plugin-basic-ssl";
|
|||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react(), tailwindcss(), basicSsl()],
|
// 🚀 basicSsl 仅 dev(本地 HMR https)需要;生产 build 跳过,
|
||||||
|
// 避免服务器容器低熵环境下生成自签名证书导致 vite build 卡住
|
||||||
|
plugins: [
|
||||||
|
react(),
|
||||||
|
tailwindcss(),
|
||||||
|
...(process.env.NODE_ENV !== "production" ? [basicSsl()] : []),
|
||||||
|
],
|
||||||
|
|
||||||
// 🚀 构建优化:将第三方巨头独立分包,利用浏览器缓存
|
// 🚀 构建优化:将第三方巨头独立分包,利用浏览器缓存
|
||||||
build: {
|
build: {
|
||||||
|
|||||||
Reference in New Issue
Block a user