pwa: zmiana na autoUpdate

This commit is contained in:
2023-06-02 19:41:33 +02:00
parent ea7c49dfb3
commit 145dc72b6b
2 changed files with 56 additions and 56 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "stacjownik", "name": "stacjownik",
"version": "1.15.0", "version": "1.15.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+55 -55
View File
@@ -1,55 +1,55 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({ export default defineConfig({
server: { server: {
port: 5001, port: 5001,
}, },
plugins: [ plugins: [
vue(), vue(),
VitePWA({ VitePWA({
registerType: 'prompt', registerType: 'autoUpdate',
workbox: { workbox: {
globPatterns: ['**/*.{js,css,html,png,svg,jpg}'], globPatterns: ['**/*.{js,css,html,png,svg,jpg}'],
runtimeCaching: [ runtimeCaching: [
{ {
urlPattern: new RegExp('^https://spythere.pl/api/getSceneries', 'i'), urlPattern: new RegExp('^https://spythere.pl/api/getSceneries', 'i'),
handler: 'NetworkFirst', handler: 'NetworkFirst',
options: { options: {
cacheName: 'sceneries-cache', cacheName: 'sceneries-cache',
expiration: { expiration: {
maxEntries: 1, maxEntries: 1,
maxAgeSeconds: 60 * 60 * 24 * 7, // <== 7 days maxAgeSeconds: 60 * 60 * 24 * 7, // <== 7 days
}, },
cacheableResponse: { cacheableResponse: {
statuses: [0, 200], statuses: [0, 200],
}, },
}, },
}, },
{ {
urlPattern: /^https:\/\/rj.td2.info.pl\/dist\/img\/thumbnails\/.*/i, urlPattern: /^https:\/\/rj.td2.info.pl\/dist\/img\/thumbnails\/.*/i,
handler: 'CacheFirst', handler: 'CacheFirst',
options: { options: {
cacheName: 'images-cache', cacheName: 'images-cache',
expiration: { expiration: {
maxEntries: 100, maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 60, maxAgeSeconds: 60 * 60 * 24 * 60,
}, },
cacheableResponse: { cacheableResponse: {
statuses: [0, 200, 404], statuses: [0, 200, 404],
}, },
}, },
}, },
], ],
}, },
devOptions: { devOptions: {
enabled: true, enabled: true,
}, },
}), }),
], ],
}); });