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

View File

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

View File

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