forked from Mirrors/elk
perf(pwa): exclude shiki from sw precache (#907)
This commit is contained in:
parent
d0675cb391
commit
04aac652cf
2 changed files with 14 additions and 1 deletions
|
@ -14,7 +14,7 @@ export const pwa: VitePWANuxtOptions = {
|
||||||
manifest: false,
|
manifest: false,
|
||||||
injectManifest: {
|
injectManifest: {
|
||||||
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm,webmanifest}'],
|
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm,webmanifest}'],
|
||||||
globIgnores: ['emojis/**'],
|
globIgnores: ['emojis/**', 'shiki/**'],
|
||||||
},
|
},
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: process.env.VITE_DEV_PWA === 'true',
|
enabled: process.env.VITE_DEV_PWA === 'true',
|
||||||
|
|
|
@ -36,6 +36,19 @@ if (import.meta.env.PROD)
|
||||||
|
|
||||||
// only cache pages and external assets on local build + start or in production
|
// only cache pages and external assets on local build + start or in production
|
||||||
if (import.meta.env.PROD) {
|
if (import.meta.env.PROD) {
|
||||||
|
// include shiki cache
|
||||||
|
registerRoute(
|
||||||
|
({ sameOrigin, url }) =>
|
||||||
|
sameOrigin && url.pathname.startsWith('/shiki/'),
|
||||||
|
new StaleWhileRevalidate({
|
||||||
|
cacheName: 'elk-shiki',
|
||||||
|
plugins: [
|
||||||
|
new CacheableResponsePlugin({ statuses: [200] }),
|
||||||
|
// 365 days max
|
||||||
|
new ExpirationPlugin({ maxAgeSeconds: 60 * 60 * 24 * 365 }),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
)
|
||||||
// include emoji icons
|
// include emoji icons
|
||||||
registerRoute(
|
registerRoute(
|
||||||
({ sameOrigin, request, url }) =>
|
({ sameOrigin, request, url }) =>
|
||||||
|
|
Loading…
Reference in a new issue