Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit 7b55f65

Browse files
committed
[pwa,sw,workbox]: set cahce id for sw workbox w commit hash;
1 parent 9da14ac commit 7b55f65

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

vite.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ const maxAgeSeconds = 365 * 24 * 60 * 60; // Cache for 1 year
1212
const headCommitHash = (): string | undefined => {
1313
try {
1414
return require('child_process')
15-
.execSync('git rev-parse HEAD')
16-
.toString();
15+
.execSync('git rev-parse HEAD')
16+
.toString();
1717
} catch (_) {
1818
return undefined;
1919
}
2020
};
21+
const COMMIT_HASH = headCommitHash();
2122

2223
// https://vitejs.dev/config/
2324
export default defineConfig({
2425
define: {
25-
__HEAD_COMMIT_HASH__: JSON.stringify(headCommitHash()),
26+
__HEAD_COMMIT_HASH__: JSON.stringify(COMMIT_HASH),
2627
},
2728
// This changes the out put dir from dist to build
2829
// comment this out if that isn't relevant for your project
@@ -35,6 +36,7 @@ export default defineConfig({
3536
VitePWA({
3637
registerType: 'autoUpdate',
3738
workbox: {
39+
cacheId: `local-llama-${COMMIT_HASH}`,
3840
globPatterns: ['**/*.{html,js,css,png,jpg,svg,ico,json,woff2,ttf,mp4}'],
3941
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, // 5 MB limit
4042
runtimeCaching: [

0 commit comments

Comments
 (0)