From 7787ec1265a05b90fb7a6bc2ae9eda915fd8ab2e Mon Sep 17 00:00:00 2001 From: Pranav Date: Sat, 10 Jan 2026 20:51:27 -0800 Subject: [PATCH] fix: Include CSS files from manifest css arrays The Vite manifest has CSS files in two places: - entry.file (main CSS files) - entry.css (CSS imported by JS modules) The previous code only read entry.file, missing CSS from entry.css. This increases precached assets from 57 to 69. Co-Authored-By: Claude Opus 4.5 --- app/javascript/service-worker/build.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/javascript/service-worker/build.js b/app/javascript/service-worker/build.js index 3eae2a591..100021269 100644 --- a/app/javascript/service-worker/build.js +++ b/app/javascript/service-worker/build.js @@ -32,17 +32,23 @@ function generateAssetManifest() { const seen = new Set(); for (const [, entry] of Object.entries(manifest)) { + // Add the main file (JS or CSS) const file = entry.file; - if (!file || seen.has(file)) continue; - seen.add(file); + if (file && !seen.has(file)) { + seen.add(file); + if (file.endsWith('.js') || file.endsWith('.css')) { + assets.push({ url: file, revision: null }); + } + } - // Only include JS and CSS files (not images, fonts, etc. - those are cached on demand) - if (file.endsWith('.js') || file.endsWith('.css')) { - assets.push({ - url: file, - // revision is null because hash is in filename - revision: null, - }); + // Add CSS files from the css array (CSS imported by JS modules) + if (entry.css) { + for (const cssFile of entry.css) { + if (!seen.has(cssFile)) { + seen.add(cssFile); + assets.push({ url: cssFile, revision: null }); + } + } } }