diff --git a/.env.development b/.env.development index 0dc3e7b..622e77d 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,4 @@ # 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config # TARO_APP_ID="开发环境下的小程序 AppID" -TARO_APP_ID=ttbfd9c96420ec8f8201 \ No newline at end of file +TARO_APP_ID_WEAPP=wxb51f0b0c3aad7cdf +TARO_APP_ID_TT=ttbfd9c96420ec8f8201 diff --git a/.env.production b/.env.production index 0202ec0..622e77d 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,4 @@ -# TARO_APP_ID="生产环境下的小程序 AppID" -TARO_APP_ID=ttbfd9c96420ec8f8201 \ No newline at end of file +# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config +# TARO_APP_ID="开发环境下的小程序 AppID" +TARO_APP_ID_WEAPP=wxb51f0b0c3aad7cdf +TARO_APP_ID_TT=ttbfd9c96420ec8f8201 diff --git a/.env.test b/.env.test index 8ee227d..622e77d 100644 --- a/.env.test +++ b/.env.test @@ -1,2 +1,4 @@ -# TARO_APP_ID="测试环境下的小程序 AppID" -TARO_APP_ID=ttbfd9c96420ec8f8201 \ No newline at end of file +# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config +# TARO_APP_ID="开发环境下的小程序 AppID" +TARO_APP_ID_WEAPP=wxb51f0b0c3aad7cdf +TARO_APP_ID_TT=ttbfd9c96420ec8f8201 diff --git a/config/index.ts b/config/index.ts index 1d13a38..42a8072 100644 --- a/config/index.ts +++ b/config/index.ts @@ -5,6 +5,16 @@ import prodConfig from './prod' // https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数 export default defineConfig<'vite'>(async (merge) => { + // 不同平台的 appId 配置 + const appIds = { + weapp: process.env.TARO_APP_ID_WEAPP || 'your-weapp-appid', + tt: process.env.TARO_APP_ID_TT || 'your-tt-appid', + alipay: process.env.TARO_APP_ID_ALIPAY || 'your-alipay-appid', + swan: process.env.TARO_APP_ID_SWAN || 'your-swan-appid', + qq: process.env.TARO_APP_ID_QQ || 'your-qq-appid', + jd: process.env.TARO_APP_ID_JD || 'your-jd-appid' + } + const baseConfig: UserConfigExport<'vite'> = { projectName: 'bw-mini-app', date: '2025-9-1', @@ -16,7 +26,7 @@ export default defineConfig<'vite'>(async (merge) => { 828: 1.81 / 2 }, sourceRoot: 'src', - outputRoot: 'dist', + outputRoot: process.env.TARO_ENV ? `dist/${process.env.TARO_ENV}` : 'dist', plugins: [ "@tarojs/plugin-generator" ], @@ -47,6 +57,31 @@ export default defineConfig<'vite'>(async (merge) => { } }, }, + // 小程序平台特定配置 + weapp: { + outputRoot: 'dist/weapp', + appId: appIds.weapp + }, + tt: { + outputRoot: 'dist/tt', + appId: appIds.tt + }, + alipay: { + outputRoot: 'dist/alipay', + appId: appIds.alipay + }, + swan: { + outputRoot: 'dist/swan', + appId: appIds.swan + }, + qq: { + outputRoot: 'dist/qq', + appId: appIds.qq + }, + jd: { + outputRoot: 'dist/jd', + appId: appIds.jd + }, h5: { publicPath: '/', staticDirectory: 'static',