Files
ToBePlayed-Frontend/vite.config.js
T
lobo cfceca5e5e
Build, Test & Push Frontend / quality-check (push) Successful in 15s
Build, Test & Push Frontend / docker (push) Successful in 27s
feat(settings): show the build version of each service
2026-09-27 10:27:01 +02:00

36 lines
1.2 KiB
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()),
// Docker build args from the CI workflow, see Dockerfile
__BUILD_COMMIT__: JSON.stringify(process.env.GIT_SHA || 'dev'),
__BUILD_TIME__: JSON.stringify(process.env.BUILD_TIME || ''),
},
resolve: {
alias: {
'@': path.resolve(import.meta.dirname, './src'),
},
},
});