import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import { viteSingleFile } from 'vite-plugin-singlefile' import { renameSync } from 'node:fs' import { join } from 'node:path' function dailyVersioning() { return { name: 'daily-versioning', enforce: 'post', writeBundle(options, bundle) { const now = new Date() const date = now.getFullYear() + String(now.getMonth() + 1).padStart(2, '0') + String(now.getDate()).padStart(2, '0') const oldPath = join(options.dir || 'dist', 'index.html') const newName = `grandclaw-archtype-${date}.html` const newPath = join(options.dir || 'dist', newName) if (bundle['index.html']) { renameSync(oldPath, newPath) } } } } // https://vite.dev/config/ export default defineConfig({ base: './', plugins: [react(), viteSingleFile(), dailyVersioning()], })