safely extract version

This commit is contained in:
Alex Holliday committed 2025-06-24 16:31:18 +08:00
1 parent 4f17e84247
commit 8d6078e2c1
1 file changed
+9 -2
+9 -2
View File
@@ -5,8 +5,15 @@ import { execSync } from "child_process";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const version =
env.VITE_APP_VERSION || execSync("git describe --tags --abbrev=0").toString().trim();
let version;
try {
version =
env.VITE_APP_VERSION ||
execSync("git describe --tags --abbrev=0").toString().trim();
} catch (error) {
version = "unknown";
}
return {
base: "/",
plugins: [svgr(), react()],