import { defineConfig } from 'vite'; import { execSync } from 'node:child_process'; // Marqueur de build : hash git court, injecté dans la page et dans /build.json. // Un HTTP 200 ne valide rien ; le marqueur, si. function hashGit(): string { try { return execSync('git rev-parse --short HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim(); } catch { return 'sans-git'; } } const BUILD_HASH = process.env.QUARTIER_BUILD_HASH ?? hashGit(); export default defineConfig({ base: '/', define: { __BUILD_HASH__: JSON.stringify(BUILD_HASH) }, build: { target: 'es2022', sourcemap: false, // Budget V1 : < 5 Mo transférés en démo, < 1,5 Mo en ambiance (ARCHITECTURE §1 bis). chunkSizeWarningLimit: 900, rollupOptions: { output: { manualChunks: { three: ['three'] }, }, }, }, plugins: [ { name: 'quartier-build-json', generateBundle() { this.emitFile({ type: 'asset', fileName: 'build.json', source: JSON.stringify({ hash: BUILD_HASH, date: new Date().toISOString() }), }); }, }, ], });