Commit 545623b1 by lijiabin

Merge branch '配置测试环境' into feature/21402-【YAYA文化岛】优化点整理

parents b02715a9 98efd42c
import { execSync } from 'node:child_process'
import { createHash } from 'node:crypto'
// 获取当前分支名 去掉空格 斜杠 换行 等特殊字符
export const getCurrentBranchName = () => {
const branchName = execSync('git branch --show-current', {
encoding: 'utf-8',
})
.trim()
.replaceAll(' ', '_')
.replaceAll('/', '_')
.replaceAll('\n', '_')
return branchName
}
// 根据分支名创建一个唯一的服务器文件夹名字
export const getDeploySlug = (branchName) => {
return `branch-${createHash('md5').update(branchName).digest('hex').slice(0, 8)}`
}
...@@ -17,6 +17,7 @@ export const app_config: { [key: string]: IConfig } = { ...@@ -17,6 +17,7 @@ export const app_config: { [key: string]: IConfig } = {
// 测试环境 暂时无测试环境部署 // 测试环境 暂时无测试环境部署
test: { test: {
// baseUrl: 'http://culture.yswg.com.cn:8089', // 线上测试机
baseUrl: 'http://192.168.2.55:8089', // 首拥本地 baseUrl: 'http://192.168.2.55:8089', // 首拥本地
loginType: 1, loginType: 1,
wxRedirect: '', wxRedirect: '',
......
...@@ -15,10 +15,12 @@ import Icons from 'unplugin-icons/vite' ...@@ -15,10 +15,12 @@ import Icons from 'unplugin-icons/vite'
import path from 'node:path' import path from 'node:path'
// 获取到执行脚本的--参数 // 获取到执行脚本的--参数
import pkg from './package.json' import pkg from './package.json'
// @ts-ignore
import { getCurrentBranchName, getDeploySlug } from './deploy/util.js'
// https://vite.dev/config/
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
return { return {
base: mode === 'test' ? `/${getDeploySlug(getCurrentBranchName())}/` : '/',
define: { define: {
__CORE_LIB_VERSION__: JSON.stringify(pkg.dependencies), __CORE_LIB_VERSION__: JSON.stringify(pkg.dependencies),
}, },
...@@ -62,7 +64,7 @@ export default defineConfig(({ mode }) => { ...@@ -62,7 +64,7 @@ export default defineConfig(({ mode }) => {
symbolId: 'icon-[dir]-[name]', symbolId: 'icon-[dir]-[name]',
}), }),
mode === 'development' && visualizer(), // 开发环境打包才需要 mode === 'development' && visualizer(), // 开发环境打包才需要
pushUpdatePlugin(), mode === 'production' && pushUpdatePlugin(), // 生产环境打包才更新推送
], ],
server: { server: {
// 是否开启 https // 是否开启 https
...@@ -80,7 +82,7 @@ export default defineConfig(({ mode }) => { ...@@ -80,7 +82,7 @@ export default defineConfig(({ mode }) => {
// }, // },
}, },
build: { build: {
minify: 'esbuild', minify: 'esbuild', // 'esbuild'
chunkSizeWarningLimit: 1000, chunkSizeWarningLimit: 1000,
rollupOptions: { rollupOptions: {
output: { output: {
......
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