2024-04-17 01:45:36 +09:00
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
import path from 'node:path'
|
|
|
|
import react from '@vitejs/plugin-react-swc'
|
|
|
|
|
feat: Add BuildInfoCard component
This commit adds a new component called BuildInfoCard. The BuildInfoCard component displays information about the build, including the Git branch, Git hash, build time, and build version. It is used in the SettingPage component.
The packages/client/vite.config.ts file is modified to define environment variables for the build information. The __BUILD_TIME__, __BUILD_VERSION__, __GIT_BRANCH__, and __GIT_HASH__ variables are defined using functions that retrieve the current build time, build version, Git branch, and Git hash respectively.
This commit introduces new functionality and improves the user experience by providing build information in the application.
2024-10-13 01:40:01 +09:00
|
|
|
import { execSync } from "child_process";
|
|
|
|
|
|
|
|
function getCurrentGitHash(): string {
|
|
|
|
const gitHash = execSync("git rev-parse HEAD")
|
|
|
|
.toString()
|
|
|
|
.trim();
|
|
|
|
return gitHash;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBuildTime(): string {
|
|
|
|
return new Date().toISOString();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBuildVersion(): string {
|
|
|
|
return process.env.BUILD_VERSION ?? getCurrentGitHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCurrentGitBranch(): string {
|
|
|
|
const gitBranch = execSync("git rev-parse --abbrev-ref HEAD")
|
|
|
|
.toString()
|
|
|
|
.trim();
|
|
|
|
return gitBranch;
|
|
|
|
}
|
|
|
|
|
2024-04-17 01:45:36 +09:00
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
|
|
return {
|
|
|
|
plugins: [react()],
|
feat: Add BuildInfoCard component
This commit adds a new component called BuildInfoCard. The BuildInfoCard component displays information about the build, including the Git branch, Git hash, build time, and build version. It is used in the SettingPage component.
The packages/client/vite.config.ts file is modified to define environment variables for the build information. The __BUILD_TIME__, __BUILD_VERSION__, __GIT_BRANCH__, and __GIT_HASH__ variables are defined using functions that retrieve the current build time, build version, Git branch, and Git hash respectively.
This commit introduces new functionality and improves the user experience by providing build information in the application.
2024-10-13 01:40:01 +09:00
|
|
|
define: {
|
|
|
|
__BUILD_TIME__: `"${getBuildTime()}"`,
|
|
|
|
__BUILD_VERSION__: `"${getBuildVersion()}"`,
|
|
|
|
__GIT_BRANCH__: `"${getCurrentGitBranch()}"`,
|
|
|
|
__GIT_HASH__: `"${getCurrentGitHash()}"`,
|
|
|
|
},
|
2024-04-17 01:45:36 +09:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
proxy: {
|
|
|
|
'/api': env.API_BASE_URL ?? 'http://localhost:8000',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}})
|