Skip to content

Commit 9d7cd11

Browse files
committed
feat: add build time and version constants to configuration
1 parent cdc1076 commit 9d7cd11

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/constants/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
declare const __BUILD_TIME__: string;
2-
31
export const DEFAULT_JSON = `{
42
"name": "JSON Formatter",
5-
"version": "1.0.0",
3+
"version": "${__BUILD_VERSION__}",
64
"description": "A beautiful JSON formatting tool",
75
"author": "const",
86
"site": "https://json.const.site",

src/types/assets.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ declare module '*.svg' {
22
const content: string;
33
export default content;
44
}
5+
declare const __BUILD_TIME__: string;
6+
declare const __BUILD_VERSION__: string;

vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
3+
import packageJson from './package.json';
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
@@ -8,5 +9,6 @@ export default defineConfig({
89
__BUILD_TIME__: JSON.stringify(
910
new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }),
1011
),
12+
__BUILD_VERSION__: JSON.stringify(packageJson.version),
1113
},
1214
});

0 commit comments

Comments
 (0)