Skip to content

Commit

Permalink
build(ui): reset i18n cache after each build
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Sep 18, 2024
1 parent c339870 commit 8ad7209
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions webapp/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions webapp/src/types/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const __BUILD_TIMESTAMP__: string;
5 changes: 5 additions & 0 deletions webapp/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8ad7209

Please sign in to comment.