diff --git a/.gitignore b/.gitignore index 9aed739..8751401 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ _build/ node_modules dist/ package-lock.json +.env.local +.env.*.local diff --git a/src/libs/config.ts b/src/libs/config.ts index 065a3bf..bd07476 100644 --- a/src/libs/config.ts +++ b/src/libs/config.ts @@ -10,9 +10,10 @@ * * see https://vitejs.dev/guide/env-and-mode */ +declare const __APP_RELEASE_VERSION__: string; export const config = { - version: import.meta.env.VITE_RELEASE_VERSION ?? "local-dev", + version: __APP_RELEASE_VERSION__ ?? "local-dev", githubArchive: import.meta.env.VITE_GITHUB_ARCHIVE_URL ?? "local-dev", homePage: import.meta.env.BASE_URL, // "https://irc.softver.org.mk/", indexPageSize: toInt(import.meta.env.VITE_IRCLOG_INDEX_PAGE_SIZE, 100), diff --git a/vite.config.ts b/vite.config.ts index a5a77f5..e0241b4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,8 +16,19 @@ const svelteConfig = { /* * https://vitejs.dev/config/ */ -export default defineConfig({ - server: { port: parseInt(process.env.npm_package_config_port) }, - build: { sourcemap: true }, - plugins: [svelte(svelteConfig)], +export default defineConfig(({mode}) => { + return { + server: { port: parseInt(process.env.npm_package_config_port) }, + build: { sourcemap: true }, + plugins: [svelte(svelteConfig)], + define: { + "__APP_RELEASE_VERSION__": JSON.stringify(version()), + } + } }); + +function version() { + const t = new Date(); + const date = t.toISOString().split('T')[0]; // YYYY-MM-DD + return `v${date}`; +}