Setup workbox to generate service worker

This commit is contained in:
JannisX11 2021-02-21 21:59:39 +01:00
parent f37a83f099
commit 18e045f744
5 changed files with 1902 additions and 421 deletions

2239
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -91,6 +91,8 @@
"dev": "electron .",
"dist": "electron-builder",
"beta": "electron-builder --windows portable",
"pwa": "node ./scripts/generate_pwa.js",
"prepublish": "npm run bundle && npm run pwa",
"webapp": "git checkout gh-pages && git merge master && git push && git checkout master"
},
"devDependencies": {
@ -99,7 +101,8 @@
"electron-builder": "^22.9.1",
"electron-notarize": "^1.0.0",
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0"
"webpack-cli": "^4.5.0",
"workbox-build": "^6.1.0"
},
"dependencies": {
"electron-updater": "^4.3.1"

22
scripts/generate_pwa.js Normal file
View File

@ -0,0 +1,22 @@
const workbox = require('workbox-build');
workbox.generateSW({
cacheId: 'blockbench',
globDirectory: './',
globPatterns: [
'./index.html',
'./favicon.png',
'./service_worker.js',
'./js/**/*',
'./lib/**/*',
'./css/**/*',
'./assets/**/*',
'./font/*',
'./lang/*',
],
swDest: './service_worker.js',
sourcemap: false
}).then(({count, size}) => {
console.log(`Generated service-worker, which will precache ${count} files, totaling ${(size/1e6).toFixed(2)} MB.`);
});

File diff suppressed because one or more lines are too long

1
workbox-1cb178f3.js Normal file

File diff suppressed because one or more lines are too long