obs-overlay-widget/vite.config.ts

30 lines
689 B
TypeScript
Raw 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, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/
export default defineConfig(({ command, mode }) => {
// 加载环境变量
const env = loadEnv(mode, process.cwd(), '')
// 根据构建环境动态设置base路径
const base = (() => {
// 开发模式使用根路径
if (command === 'serve') {
return '/'
}
// 生产模式检查是否有指定的base路径用于GitHub Pages
if (env.VITE_BASE_PATH) {
return env.VITE_BASE_PATH
}
// 默认使用相对路径,适用于任何部署场景
return './'
})()
return {
plugins: [vue()],
base,
}
})