Remove resource caching from service worker

This commit is contained in:
Niels van Velzen 2023-10-16 16:14:09 +02:00
parent 4882d9c8cc
commit f7f546f15f
4 changed files with 5 additions and 1514 deletions

1488
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,6 @@
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.15.1",
"webpack-merge": "5.9.0",
"workbox-webpack-plugin": "6.6.0",
"worker-loader": "3.0.8"
},
"dependencies": {
@ -118,9 +117,7 @@
"sortablejs": "1.15.0",
"swiper": "9.3.2",
"webcomponents.js": "0.7.24",
"whatwg-fetch": "3.6.2",
"workbox-core": "6.6.0",
"workbox-precaching": "6.6.0"
"whatwg-fetch": "3.6.2"
},
"browserslist": [
"last 2 Firefox versions",

View File

@ -1,13 +1,5 @@
/* eslint-env serviceworker */
/* eslint-disable import/namespace,import/named */
import { skipWaiting, clientsClaim } from 'workbox-core';
import { precacheAndRoute } from 'workbox-precaching';
/* eslint-enable import/namespace,import/named */
skipWaiting();
clientsClaim();
function getApiClient(serverId) {
return Promise.resolve(window.connectionManager.getApiClient(serverId));
}
@ -44,9 +36,5 @@ self.addEventListener('notificationclick', function (event) {
event.waitUntil(executeAction(action, data, serverId));
}, false);
// Do not precache files when running with webpack dev server so live reload works as expected
if (!__WEBPACK_SERVE__) { // eslint-disable-line no-undef
// this is needed by the webpack Workbox plugin
/* eslint-disable-next-line no-restricted-globals,no-undef */
precacheAndRoute(self.__WB_MANIFEST);
}
/* eslint-disable-next-line no-restricted-globals -- self is valid in a serviceworker environment */
self.addEventListener('activate', () => self.clients.claim());

View File

@ -1,15 +1,7 @@
const path = require('path');
const common = require('./webpack.common');
const { merge } = require('webpack-merge');
const WorkboxPlugin = require('workbox-webpack-plugin');
module.exports = merge(common, {
mode: 'production',
entry: { 'main.jellyfin': './index.jsx' },
plugins: [
new WorkboxPlugin.InjectManifest({
swSrc: path.resolve(__dirname, 'src/serviceworker.js'),
swDest: 'serviceworker.js'
})
]
entry: { 'main.jellyfin': './index.jsx' }
});