Files
ToBePlayed-Frontend/vite.config.js
T
lobo 25d2f0d0bd
Build, Test & Push Frontend / quality-check (push) Successful in 14s
Build, Test & Push Frontend / docker (push) Successful in 26s
fix(ui): stop old translations and page shrink on Android
The translation files get a content version in their URL, so a
browser that cached an old file loads the new one. On touch
screens the scroll lock of menus and selects no longer adds a
right margin: Android Chrome reported one and the whole page
became narrower.
2026-09-26 06:29:57 +02:00

33 lines
1017 B
JavaScript

import {createHash} from 'node:crypto';
import {readdirSync, readFileSync} from 'node:fs';
import path from 'node:path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
const translationsDir = path.resolve(import.meta.dirname, 'public/i18n');
// Changes whenever a translation changes, so the browser loads the new file under a new URL.
const translationsVersion = () => {
const hash = createHash('sha256');
for (const file of readdirSync(translationsDir).filter((name) => name.endsWith('.json')).sort()) {
hash.update(readFileSync(path.join(translationsDir, file)));
}
return hash.digest('hex').slice(0, 12);
};
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
define: {
__TRANSLATIONS_VERSION__: JSON.stringify(translationsVersion()),
},
resolve: {
alias: {
'@': path.resolve(import.meta.dirname, './src'),
},
},
});