From c115c5fc3ecceaee3382e31e91690b0789bbdd1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=90=A6?= <40948901+liuqi-web@users.noreply.github.com> Date: Thu, 26 Jun 2025 17:56:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:test=E6=A8=A1=E5=BC=8F=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E5=8A=A0=E8=BD=BD=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/manifest.config.ts b/manifest.config.ts index b498ca4..63c3239 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -4,8 +4,14 @@ import process from 'node:process' import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest' import { loadEnv } from 'vite' +// 手动解析命令行参数获取 mode +function getMode() { + const args = process.argv.slice(2) + const modeFlagIndex = args.findIndex(arg => arg === '--mode') + return modeFlagIndex !== -1 ? args[modeFlagIndex + 1] : args[0] === 'build' ? 'production' : 'development' // 默认 development +} // 获取环境变量的范例 -const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env')) +const env = loadEnv(getMode(), path.resolve(process.cwd(), 'env')) const { VITE_APP_TITLE, VITE_UNI_APPID, From 934ba914ec28d92554eb6cce4382ab9b4ca92fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=90=A6?= <40948901+liuqi-web@users.noreply.github.com> Date: Fri, 27 Jun 2025 18:05:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:h5=E6=97=B6base=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.config.ts | 2 +- vite.config.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifest.config.ts b/manifest.config.ts index 63c3239..503f85f 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -30,7 +30,7 @@ export default defineManifestConfig({ 'locale': VITE_FALLBACK_LOCALE, // 'zh-Hans' 'h5': { router: { - base: VITE_APP_PUBLIC_BASE, + // base: VITE_APP_PUBLIC_BASE, }, }, /* 5+App特有相关 */ diff --git a/vite.config.ts b/vite.config.ts index 1c0eca1..7d6224f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -50,12 +50,13 @@ export default async ({ command, mode }) => { VITE_SHOW_SOURCEMAP, VITE_APP_PROXY, VITE_APP_PROXY_PREFIX, + VITE_APP_PUBLIC_BASE } = env console.log('环境变量 env -> ', env) return defineConfig({ envDir: './env', // 自定义env目录 - + base: VITE_APP_PUBLIC_BASE, plugins: [ UniPages({ exclude: ['**/components/**/**.*'],