feat: 构建输出按日期命名

添加 dailyVersioning Vite 插件,将构建输出从 index.html 改为 grandclaw-archtype-YYYYMMDD.html 格式
This commit is contained in:
2026-03-28 12:59:45 +08:00
parent 1455cc850d
commit 46016b0786
2 changed files with 50 additions and 1 deletions

View File

@@ -1,9 +1,32 @@
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()],
plugins: [react(), viteSingleFile(), dailyVersioning()],
})