ai-digital-live/vite.config.ts

72 lines
2.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import {resolve} from "path";
import AppPackage from './package.json'
import dayjs from "dayjs";
// 播放器 SDK Web 端TCPlayer自 5.0.0 版本起需获取 License 授权后方可使用。
// <p>https://cloud.tencent.com/document/product/881/77877#.E5.87.86.E5.A4.87.E5.B7.A5.E4.BD.9C</p>
const TCPlayerLicense = 'https://license.vod2.myqcloud.com/license/v2/1328581896_1/v_cube.license'
const DevServerList:{
[key:string]:string
} = {
'test':'https://fm-admin.starbitech.com',
'development':'http://192.168.0.231:9999',
'lang-en':'https://mh.starbitech.com'
}
// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
const devServerHost = DevServerList[mode] || 'http://192.168.0.231:9999'
const AUTH_TOKEN_KEY = mode == 'production' ? 'digital-person-token' : `digital-person-token_${mode}`
if (mode !== 'production') {
console.log('dev server is', devServerHost, mode)
}
return {
plugins: [react()],
base: process.env.PUBLIC_PATH || (mode == 'relative' ? './' : '/'),
define: {
AppConfig: JSON.stringify({
SITE_URL: process.env.APP_SITE_URL || null,
API_PREFIX: process.env.APP_API_PREFIX || '/mgmt/v1/metahuman',
AUTH_TOKEN_KEY: process.env.AUTH_TOKEN_KEY || AUTH_TOKEN_KEY,
AUTHED_PERSON_DATA_KEY: process.env.AUTHED_PERSON_DATA_KEY || 'digital-person-user-info',
ONLY_LIVE: process.env.ONLY_LIVE || 'no',
APP_LANG: process.env.APP_LANGUAGE,
TCPlayerLicense
}),
AppMode: JSON.stringify(mode),
AppBuildVersion: JSON.stringify(AppPackage.name + '-' + AppPackage.version + '-' + dayjs().format('YYYYMMDDHH_mmss'))
},
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
css: {
preprocessorOptions: {
scss: {
api: 'modern'
}
}
},
server: {
port: 10021,
proxy: {
'/mgmt': {
target: `${devServerHost}`, // http://124.220.14.192/ 192.168.0.231:9999
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
},
'/api': {
target: `${devServerHost}`,
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
}
})