From 6a582f0a57b74f2def179a79cdbdf54273f9f6e6 Mon Sep 17 00:00:00 2001 From: Burt <1020103647@qq.com> Date: Mon, 15 Jan 2024 09:58:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(manifest):=20=E8=AF=BB=E5=8F=96env=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env | 4 ++-- manifest.config.ts | 11 ++++++++--- src/manifest.json | 6 +++--- vite.config.ts | 2 ++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/env/.env b/env/.env index 54a92a0..086f1b5 100644 --- a/env/.env +++ b/env/.env @@ -1,5 +1,5 @@ -VITE_APP_TITLE = 'vue3-uniapp' +VITE_APP_TITLE = 'unifly-uniapp' VITE_APP_PORT = 9000 -VIRW_UNI_APPID = 'H5871D791' +VITE_UNI_APPID = 'H5871D791' VITE_WX_APPID = 'wxa2abb91f64032a2b' diff --git a/manifest.config.ts b/manifest.config.ts index f63ec20..8a7243d 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -1,9 +1,14 @@ // manifest.config.ts import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest' +import path from 'node:path' +import { loadEnv } from 'vite' +const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env')) +// console.log(env) +const { VITE_APP_TITLE, VITE_UNI_APPID, VITE_WX_APPID } = env export default defineManifestConfig({ - name: 'unifly', - appid: '', + name: VITE_APP_TITLE, + appid: VITE_UNI_APPID, description: '', versionName: '1.0.0', versionCode: '100', @@ -61,7 +66,7 @@ export default defineManifestConfig({ quickapp: {}, /* 小程序特有相关 */ 'mp-weixin': { - appid: '', + appid: VITE_WX_APPID, setting: { urlCheck: false, }, diff --git a/src/manifest.json b/src/manifest.json index 2ca3650..75a22d2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { - "name": "unifly", - "appid": "", + "name": "unifly-uniapp", + "appid": "H5871D791", "description": "", "versionName": "1.0.0", "versionCode": "100", @@ -46,7 +46,7 @@ }, "quickapp": {}, "mp-weixin": { - "appid": "", + "appid": "wxa2abb91f64032a2b", "setting": { "urlCheck": false }, diff --git a/vite.config.ts b/vite.config.ts index 1e61bb5..c49e0cb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,6 +23,8 @@ import autoprefixer from 'autoprefixer' // https://vitejs.dev/config/ export default ({ command, mode }) => { + console.log(mode === process.env.NODE_ENV) + // mode: 区分生产环境还是开发环境 console.log(command, mode) // pnpm dev:h5 时得到 => serve development