Skip to content

Commit 0b3e3d9

Browse files
committed
chore: output version to version.json
1 parent c1bd66a commit 0b3e3d9

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

frontend/firebase.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@
103103
"value": "no-cache, no-store, must-revalidate"
104104
}
105105
]
106+
},
107+
{
108+
"source": "/version.json",
109+
"headers": [
110+
{
111+
"key": "Cache-Control",
112+
"value": "no-cache, no-store, must-revalidate"
113+
}
114+
]
106115
}
107116
]
108117
}

frontend/static/version.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "version": "DEVELOPMENT_CLIENT" }

frontend/vite.config.prod.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import path from "node:path";
77
import { splitVendorChunkPlugin } from "vite";
88
import childProcess from "child_process";
99
import { checker } from "vite-plugin-checker";
10+
import { writeFileSync } from "fs";
1011

1112
function pad(numbers, maxLength, fillString) {
1213
return numbers.map((number) =>
@@ -31,7 +32,7 @@ function buildClientVersion() {
3132
.execSync("git rev-parse --short HEAD")
3233
.toString();
3334

34-
return `${version}.${commitHash}`;
35+
return `${version}.${commitHash}`.replace(/\n/g, "");
3536
} catch (e) {
3637
return `${version}.unknown-hash`;
3738
}
@@ -57,6 +58,17 @@ export default {
5758
});
5859
},
5960
},
61+
{
62+
name: "generate-version-json",
63+
apply: "build",
64+
65+
closeBundle() {
66+
const version = buildClientVersion();
67+
const versionJson = JSON.stringify({ version });
68+
const versionPath = path.resolve(__dirname, "dist/version.json");
69+
writeFileSync(versionPath, versionJson);
70+
},
71+
},
6072
{
6173
name: "vite-plugin-webfonts-preview",
6274
apply: "build",

0 commit comments

Comments
 (0)