From 2414ca7cbf1cdc3089dfc44c9734bb55fd2ade7a Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Thu, 22 Oct 2026 15:41:33 +0200 Subject: [PATCH] fix(core): add server version to frontend chunk file names Lazy-loaded chunks and their CSS are requested without the `?v=` cache buster, so include the server version in their file names to make sure browsers and proxies never reuse them across updates. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Simon L. --- build/frontend/vite.config.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build/frontend/vite.config.ts b/build/frontend/vite.config.ts index c3010631d59db..e4c1f7d99e23e 100644 --- a/build/frontend/vite.config.ts +++ b/build/frontend/vite.config.ts @@ -4,8 +4,14 @@ */ import { createAppConfig } from '@nextcloud/vite-config' +import { readFileSync } from 'node:fs' import { resolve } from 'node:path' +// Chunks and assets are loaded without the `?v=` cache buster, so the server version is part of their file names +const serverVersion = readFileSync(resolve(import.meta.dirname, '../..', 'version.php'), 'utf-8') + .match(/\$OC_VersionString = '([^']+)';/)![1] + .replaceAll(/[^\w.-]/g, '-') + const modules = { appstore: { main: resolve(import.meta.dirname, 'apps/appstore/src', 'main.ts'), @@ -167,12 +173,12 @@ export default createAppConfig(Object.fromEntries(viteModuleEntries), { rollupOptions: { output: { entryFileNames: '[name].mjs', - chunkFileNames: '[name]-[hash].chunk.mjs', + chunkFileNames: `[name]-${serverVersion}-[hash].chunk.mjs`, assetFileNames({ originalFileNames }) { const apps = originalFileNames.map((name) => name.match(/apps\/([^/]+)\//)?.[1]) .filter(Boolean) const appId = apps.length === 1 ? apps[0] : 'common' - return `${appId}-[name]-[hash][extname]` + return `${appId}-[name]-${serverVersion}-[hash][extname]` }, experimentalMinChunkSize: 100 * 1024, /* // with rolldown-vite: