mirror of
https://github.com/elk-zone/elk.git
synced 2025-02-17 15:59:49 +03:00
chore: check web manifest via precaching
This commit is contained in:
parent
0cfd6a1d33
commit
3f3cb16979
2 changed files with 8 additions and 8 deletions
|
@ -13,8 +13,8 @@ export const pwa: VitePWANuxtOptions = {
|
||||||
includeManifestIcons: false,
|
includeManifestIcons: false,
|
||||||
manifest: false,
|
manifest: false,
|
||||||
injectManifest: {
|
injectManifest: {
|
||||||
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm}'],
|
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm,webmanifest}'],
|
||||||
globIgnores: ['emojis/**', 'shiki/**', 'manifest**.webmanifest', 'pwa-*.png', 'maskable-icon.png', 'shortcuts/**', 'screenshots/**'],
|
globIgnores: ['emojis/**', 'shiki/**'/* , 'manifest**.webmanifest', 'pwa-*.png', 'maskable-icon.png', 'shortcuts/**', 'screenshots/**' */],
|
||||||
manifestTransforms: [(entries) => {
|
manifestTransforms: [(entries) => {
|
||||||
const manifest = entries.map((entry) => {
|
const manifest = entries.map((entry) => {
|
||||||
if (entry.url.length > 1 && entry.url[0] !== '/')
|
if (entry.url.length > 1 && entry.url[0] !== '/')
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
|
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
|
||||||
import { NavigationRoute, registerRoute } from 'workbox-routing'
|
import { NavigationRoute, registerRoute } from 'workbox-routing'
|
||||||
import { CacheableResponsePlugin } from 'workbox-cacheable-response'
|
import { CacheableResponsePlugin } from 'workbox-cacheable-response'
|
||||||
import { NetworkFirst, StaleWhileRevalidate } from 'workbox-strategies'
|
import { StaleWhileRevalidate } from 'workbox-strategies'
|
||||||
import { ExpirationPlugin } from 'workbox-expiration'
|
import { ExpirationPlugin } from 'workbox-expiration'
|
||||||
|
|
||||||
import { onNotificationClick, onPush } from './web-push-notifications'
|
import { onNotificationClick, onPush } from './web-push-notifications'
|
||||||
|
@ -33,7 +33,7 @@ if (import.meta.env.DEV)
|
||||||
// deny api and server page calls
|
// deny api and server page calls
|
||||||
let denylist: undefined | RegExp[]
|
let denylist: undefined | RegExp[]
|
||||||
if (import.meta.env.PROD) {
|
if (import.meta.env.PROD) {
|
||||||
const pwaIcons = /^\/(pwa-.*|maskable-icon|shortcuts\/.*|screenshots\/.*)\.(png|webp)/
|
// const pwaIcons = /^\/(pwa-.*|maskable-icon|shortcuts\/.*|screenshots\/.*)\.(png|webp)/
|
||||||
denylist = [
|
denylist = [
|
||||||
/^\/api\//,
|
/^\/api\//,
|
||||||
/^\/login\//,
|
/^\/login\//,
|
||||||
|
@ -47,14 +47,14 @@ if (import.meta.env.PROD) {
|
||||||
// exclude sw: if the user navigates to it, fallback to index.html
|
// exclude sw: if the user navigates to it, fallback to index.html
|
||||||
/^\/sw\.js$/,
|
/^\/sw\.js$/,
|
||||||
// exclude web manifest icons
|
// exclude web manifest icons
|
||||||
pwaIcons,
|
// pwaIcons,
|
||||||
// exclude web manifest: has its own cache, if the user navigates to it, fallback to index.html
|
// exclude web manifest: has its own cache, if the user navigates to it, fallback to index.html
|
||||||
/^\/manifest-(.*)\.webmanifest$/,
|
/// ^\/manifest-(.*)\.webmanifest$/,
|
||||||
]
|
]
|
||||||
|
|
||||||
// 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
|
||||||
// include webmanifest and images cache
|
// include webmanifest and images cache
|
||||||
registerRoute(
|
/* registerRoute(
|
||||||
({ request, sameOrigin, url }) =>
|
({ request, sameOrigin, url }) =>
|
||||||
sameOrigin && ((
|
sameOrigin && ((
|
||||||
request.destination === 'manifest' && url.pathname.startsWith('/manifest-')
|
request.destination === 'manifest' && url.pathname.startsWith('/manifest-')
|
||||||
|
@ -73,7 +73,7 @@ if (import.meta.env.PROD) {
|
||||||
new ExpirationPlugin({ maxEntries: 100 }),
|
new ExpirationPlugin({ maxEntries: 100 }),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
)
|
) */
|
||||||
// include shiki cache
|
// include shiki cache
|
||||||
registerRoute(
|
registerRoute(
|
||||||
({ sameOrigin, url }) =>
|
({ sameOrigin, url }) =>
|
||||||
|
|
Loading…
Add table
Reference in a new issue