Skip to content

Commit 4cca580

Browse files
committed
fix: client version potentially being different during build
!nuf
1 parent e5d8bd3 commit 4cca580

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

frontend/vite.config.prod.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function pad(numbers, maxLength, fillString) {
2020
);
2121
}
2222

23-
function buildClientVersion() {
23+
const CLIENT_VERSION = (() => {
2424
const date = new Date();
2525
const versionPrefix = pad(
2626
[date.getFullYear(), date.getMonth() + 1, date.getDate()],
@@ -41,7 +41,7 @@ function buildClientVersion() {
4141
} catch (e) {
4242
return `${version}_unknown-hash`;
4343
}
44-
}
44+
})();
4545

4646
/** Enable for font awesome v6 */
4747
/*
@@ -68,7 +68,7 @@ export default {
6868
apply: "build",
6969

7070
closeBundle() {
71-
const version = buildClientVersion();
71+
const version = CLIENT_VERSION;
7272
const versionJson = JSON.stringify({ version });
7373
const versionPath = path.resolve(__dirname, "dist/version.json");
7474
writeFileSync(versionPath, versionJson);
@@ -147,7 +147,7 @@ export default {
147147
org: "monkeytype",
148148
project: "frontend",
149149
release: {
150-
name: buildClientVersion(),
150+
name: CLIENT_VERSION,
151151
setCommits: {
152152
commit: "HEAD",
153153
previousCommit: "HEAD^",
@@ -287,7 +287,7 @@ export default {
287287
process.env.BACKEND_URL || "https://api.monkeytype.com"
288288
),
289289
IS_DEVELOPMENT: JSON.stringify(false),
290-
CLIENT_VERSION: JSON.stringify(buildClientVersion()),
290+
CLIENT_VERSION: JSON.stringify(CLIENT_VERSION),
291291
RECAPTCHA_SITE_KEY: JSON.stringify(process.env.RECAPTCHA_SITE_KEY),
292292
QUICK_LOGIN_EMAIL: undefined,
293293
QUICK_LOGIN_PASSWORD: undefined,

0 commit comments

Comments
 (0)