From c5fcb90683faa50bb2c8c4e079891f31473c32a0 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Wed, 3 Jun 2026 21:12:08 +0200 Subject: [PATCH] Include emitted chunks in release manifest --- vite.config.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/vite.config.js b/vite.config.js index c1a983ee..1645c2a2 100644 --- a/vite.config.js +++ b/vite.config.js @@ -130,6 +130,32 @@ function releaseManifestHash(filePath) { } } +function releaseDistAssetUrls(outputDirectory) { + const assetUrls = [] + const walk = (directory) => { + for (const entry of fs.readdirSync(directory, { withFileTypes: true })) { + const absolutePath = path.join(directory, entry.name) + const relativePath = path.relative(outputDirectory, absolutePath).replace(/\\/g, '/') + + if (entry.isDirectory()) { + walk(absolutePath) + continue + } + if (!entry.isFile()) { + continue + } + if (relativePath === 'release-manifest.json' || relativePath === '.htaccess') { + continue + } + + assetUrls.push(`/${relativePath}`) + } + } + + walk(outputDirectory) + return assetUrls +} + function patchBuefyCssMediaQuery() { return { name: 'patch-buefy-css-media-query', @@ -275,6 +301,7 @@ function releaseMetadataManifest() { const releaseEntry = JSON.parse(fs.readFileSync(releaseEntryPath, 'utf8')) const indexHtml = fs.readFileSync(indexPath, 'utf8') const rootFiles = fs.readdirSync(outputDirectory) + const emittedAssetUrls = releaseDistAssetUrls(outputDirectory) const indexAssetUrls = Array.from(indexHtml.matchAll(/\b(?:href|src)=["']([^"']+)["']/g)) .map((match) => releaseUrlPath(match[1], '/index.html')) .filter(Boolean) @@ -318,6 +345,7 @@ function releaseMetadataManifest() { const criticalAssetUrls = Array.from(new Set([ '/index.html', '/release-entry.json', + ...emittedAssetUrls, ...indexAssetUrls, ...releaseEntryAssetUrls, ...pwaAssetUrls