diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs index 7d6029d4b..86d523a6f 100644 --- a/client/.eslintrc.cjs +++ b/client/.eslintrc.cjs @@ -16,4 +16,8 @@ module.exports = { "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], "react/no-unescaped-entities": "off", }, + globals: { + __APP_VERSION__: "readonly", + process: "readonly", + }, }; diff --git a/client/src/Pages/Settings/SettingsAbout.jsx b/client/src/Pages/Settings/SettingsAbout.jsx index 861d2f30c..a80351393 100644 --- a/client/src/Pages/Settings/SettingsAbout.jsx +++ b/client/src/Pages/Settings/SettingsAbout.jsx @@ -21,7 +21,7 @@ const SettingsAbout = () => { - {t("common.appName")} {2.1} + {t("common.appName")} {__APP_VERSION__} {t("settingsPage.aboutSettings.labelDevelopedBy")} diff --git a/client/vite.config.js b/client/vite.config.js index dc84ce055..96151c0b3 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -1,12 +1,27 @@ -import { defineConfig } from "vite"; +import { defineConfig, loadEnv } from "vite"; import react from "@vitejs/plugin-react"; import svgr from "vite-plugin-svgr"; +import { execSync } from "child_process"; -// https://vitejs.dev/config/ -export default defineConfig({ - base: "/", - plugins: [svgr(), react()], - optimizeDeps: { - include: ["@mui/material/Tooltip", "@emotion/styled"], - }, +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ""); + 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()], + optimizeDeps: { + include: ["@mui/material/Tooltip", "@emotion/styled"], + }, + define: { + __APP_VERSION__: JSON.stringify(version), + }, + }; });