update:1.添加版本检查

This commit is contained in:
xiamuceer
2025-11-23 14:13:42 +08:00
parent c14a963d0f
commit b719fc62e7
5 changed files with 300 additions and 30 deletions
+8
View File
@@ -1,11 +1,19 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { readFileSync } from 'fs'
import { resolve } from 'path'
// 读取 package.json 获取版本号
const packageJson = JSON.parse(
readFileSync(resolve(__dirname, 'package.json'), 'utf-8')
)
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
// 定义全局常量,在构建时注入
define: {
'import.meta.env.VITE_APP_VERSION': JSON.stringify(packageJson.version),
'import.meta.env.VITE_BUILD_TIME': JSON.stringify(
new Date().toISOString().split('T')[0]
),