Commit 80336e8e by 王宝涛

chore(config): 更新环境配置和构建设置

- 在 .env.test 中添加中文注释并修改默认配置值
- 将 docker-compose.yml 中的服务名从 vue-app 更改为 xjrsoft-vue
- 在 Dockerfile 中添加构建参数支持不同环境模式
- 在 package.json 中添加 production 构建脚本命令


(cherry picked from commit 8da7e135)
parent 19ad993c
NODE_ENV=production # 是否开启mock
# Whether to open mock
VITE_USE_MOCK = true VITE_USE_MOCK = true
# public path # 资源公共路径,需要以 / 开头和结尾
VITE_PUBLIC_PATH = / VITE_PUBLIC_PATH = /
# Delete console # 是否删除Console.log
VITE_DROP_CONSOLE = true VITE_DROP_CONSOLE = true
# Whether to enable gzip or brotli compression # 打包是否输出gz|br文件
# Optional: gzip | brotli | none # 可选: gzip | brotli | none
# If you need multiple forms, you can use `,` to separate # 也可以有多个, 例如 ‘gzip’|'brotli',这样会同时生成 .gz和.br文件
VITE_BUILD_COMPRESS = 'none' VITE_BUILD_COMPRESS = 'gzip'
# Whether to delete origin files when using compress, default false # 使用compress时是否删除源文件,默认false
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
# Basic interface address SPA # 接口地址 可以由nginx做转发或者直接写实际地址
VITE_GLOB_API_URL=/basic-api VITE_GLOB_API_URL=http://112.230.195.2:8053
# File upload address, optional
# It can be forwarded by nginx or write the actual address directly # 文件上传地址 可以由nginx做转发或者直接写实际地址
VITE_GLOB_UPLOAD_URL=/upload VITE_GLOB_UPLOAD_URL = /system/oss/upload
# 文件预览接口 可选 # 文件预览接口 可选
VITE_GLOB_UPLOAD_PREVIEW = http://114.116.210.204:8012/onlinePreview?url= VITE_GLOB_UPLOAD_PREVIEW = http://112.230.195.2:9012/onlinePreview?url=
#外部url地址 #外部url地址
VITE_GLOB_OUT_LINK_URL = http://localhost:4100,http://localhost:8827 VITE_GLOB_OUT_LINK_URL = http://vue.xjrsoft.com:3200
#打印项目地址 #打印项目地址
VITE_GLOB_PRINT_BASE_URL = http://114.116.210.204:3300 VITE_GLOB_PRINT_BASE_URL = https://vue.xjrsoft.com:7002
#IM URL 地址 #IM URL 地址
VITE_GLOB_IM_LINK_URL = http://localhost:8827 VITE_GLOB_IM_LINK_URL = http://localhost:8827
# Interface prefix #调查问卷地址
VITE_GLOB_API_URL_PREFIX= VITE_GLOB_QN_LINK_URL = https://vue.xjrsoft.com
# Whether to enable image compression # 接口地址前缀,有些系统所有接口地址都有前缀,可以在这里统一加,方便切换
VITE_USE_IMAGEMIN= true VITE_GLOB_API_URL_PREFIX =
# use pwa # 打包是否开启pwa功能
VITE_USE_PWA = false VITE_USE_PWA = false
# Is it compatible with older browsers # 是否启用官网代码
VITE_LEGACY = false VITE_GLOB_PRODUCTION = true
# 帆软服务地址
VITE_GLOB_FINE_REPORT_URL = http://127.0.0.1:8075
...@@ -23,7 +23,8 @@ RUN pnpm install --frozen-lockfile ...@@ -23,7 +23,8 @@ RUN pnpm install --frozen-lockfile
COPY . . COPY . .
# 执行构建命令 (假设你的构建脚本是 build,输出到 dist 目录) # 执行构建命令 (假设你的构建脚本是 build,输出到 dist 目录)
RUN pnpm run build ARG BUILD_MODE=production
RUN pnpm run build:${BUILD_MODE}
# ========================================== # ==========================================
# 阶段 2: 生产环境 (Production) # 阶段 2: 生产环境 (Production)
......
services: services:
vue-app: xjrsoft-vue:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
args:
BUILD_MODE: production
image: xjrsoft-vue:1.0.0 image: xjrsoft-vue:1.0.0
container_name: xjrsoft-vue container_name: xjrsoft-vue
ports: ports:
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"serve": "npm run dev", "serve": "npm run dev",
"dev": "vite", "dev": "vite",
"build": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=8192 vite build && esno ./build/script/postBuild.ts", "build": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=8192 vite build && esno ./build/script/postBuild.ts",
"build:production": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=8192 vite build && esno ./build/script/postBuild.ts",
"build:test": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode test && esno ./build/script/postBuild.ts", "build:test": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode test && esno ./build/script/postBuild.ts",
"build:no-cache": "pnpm clean:cache && npm run build", "build:no-cache": "pnpm clean:cache && npm run build",
"report": "cross-env REPORT=true npm run build", "report": "cross-env REPORT=true npm run build",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment