diff --git a/frontend/vite.config.js b/frontend/vite.config.js index c67b368..1911d48 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -3,59 +3,48 @@ import react from '@vitejs/plugin-react' import { readFileSync, writeFileSync } from 'fs' import { join } from 'path' -// 从 config/VERSION 文件读取版本号 function getVersion() { try { - const versionFile = join(__dirname, 'config', 'VERSION') - const content = readFileSync(versionFile, 'utf-8').trim() - // 移除 VERSION= 前缀 - if (content.startsWith('VERSION=')) { - return content.substring(7).trim() - } - return content || '0.0.0' + const versionFile = join(__dirname, '..', 'config', 'VERSION') + const content = readFileSync(versionFile, 'utf-8') + const match = content.match(/^VERSION=(.*)$/m) + return match ? match[1].trim() : '0.0.0' } catch (e) { - console.error('读取 VERSION 文件失败:', e.message) return '0.0.0' } } const APP_VERSION = getVersion() -console.log('📦 构建版本:v' + APP_VERSION) -// 构建后执行 - 更新 dist/index.html 的 title function updateHtmlTitle() { - return { - name: 'update-html-title', - closeBundle() { - try { - const htmlPath = join(__dirname, 'dist', 'index.html') - let htmlContent = readFileSync(htmlPath, 'utf-8') - // 替换