(WIP) 重构客户端

This commit is contained in:
CrescentLeaf
2025-12-07 18:31:42 +08:00
parent 34d46a85f1
commit 20986af1ba
23 changed files with 714 additions and 347 deletions

View File

@@ -2,6 +2,36 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import config from '../server/config.ts'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { execSync } from 'child_process'
import fs from 'node:fs/promises'
const gitHash = execSync('git rev-parse --short HEAD')
.toString()
.trim()
const gitFullHash = execSync('git rev-parse HEAD')
.toString()
.trim()
const gitBranch = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim()
const versionEnv = {
define: {
__APP_VERSION__: JSON.stringify(JSON.parse(await fs.readFile('package.json', 'utf-8')).version),
__GIT_HASH__: JSON.stringify(gitHash),
__GIT_HASH_FULL__: JSON.stringify(gitFullHash),
__GIT_BRANCH__: JSON.stringify(gitBranch),
__BUILD_TIME__: JSON.stringify(new Date().toLocaleString('zh-CN')),
}
}
function gitHashPlugin() {
return {
name: 'git-hash-plugin',
config() {
return versionEnv
}
}
}
// https://vite.dev/config/
export default defineConfig({
@@ -14,7 +44,8 @@ export default defineConfig({
global: true,
process: true,
},
})
}),
gitHashPlugin(),
],
build: {
sourcemap: true,