feat(web): show build info and theme menu [CI]
This commit is contained in:
1 parent
98a5e67f82
commit
89cd92f7ee
10 files changed
+80
-3
No files matched your search
@@ -1,9 +1,30 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
const webRoot = fileURLToPath(new URL('.', import.meta.url));
|
||||
const webPackage = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')) as { version: string };
|
||||
|
||||
function gitValue(...args: string[]): string {
|
||||
try {
|
||||
return execFileSync('git', args, { cwd: webRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || 'unknown';
|
||||
} catch {
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
const buildInfo = {
|
||||
frontendVersion: webPackage.version,
|
||||
commit: process.env.WEBDROP_BUILD_COMMIT ?? gitValue('rev-parse', '--short=12', 'HEAD'),
|
||||
tag: process.env.WEBDROP_BUILD_TAG ?? gitValue('describe', '--tags', '--exact-match', 'HEAD'),
|
||||
builtAt: process.env.WEBDROP_BUILD_TIME ?? new Date().toISOString(),
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
define: { __WEBDROP_BUILD_INFO__: JSON.stringify(buildInfo) },
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
|
||||
Reference in new issue
Block a user