diff --git a/webapp/src/i18n.ts b/webapp/src/i18n.ts index 980cffbf89..c4ee599be1 100644 --- a/webapp/src/i18n.ts +++ b/webapp/src/i18n.ts @@ -2,7 +2,6 @@ import i18n from "i18next"; import Backend from "i18next-http-backend"; import LanguageDetector from "i18next-browser-languagedetector"; import { initReactI18next } from "react-i18next"; -import { version } from "../package.json"; i18n // load translation using xhr -> see /public/locales @@ -20,7 +19,7 @@ i18n backend: { loadPath: `${ import.meta.env.BASE_URL - }locales/{{lng}}/{{ns}}.json?v=${version}`, + }locales/{{lng}}/{{ns}}.json?id=${__BUILD_TIMESTAMP__}`, }, react: { useSuspense: false, diff --git a/webapp/src/types/vite-env.d.ts b/webapp/src/types/vite-env.d.ts new file mode 100644 index 0000000000..208bfed10a --- /dev/null +++ b/webapp/src/types/vite-env.d.ts @@ -0,0 +1 @@ +declare const __BUILD_TIMESTAMP__: string; diff --git a/webapp/vite.config.ts b/webapp/vite.config.ts index 7cce8d327b..957782ee20 100644 --- a/webapp/vite.config.ts +++ b/webapp/vite.config.ts @@ -11,6 +11,11 @@ export default defineConfig(({ mode }) => { return { // Serve the web app at the `/static` entry point on Desktop mode (cf. 'antarest/main.py') base: isDesktopMode ? "/static/" : "/", + // Entries will be defined as globals during dev and statically replaced during build + define: { + // Not working in dev without `JSON.stringify` + __BUILD_TIMESTAMP__: JSON.stringify(Date.now()), + }, esbuild: { // Remove logs safely when building production bundle // https://esbuild.github.io/api/#pure