Kind of fix registering the service worker

This commit is contained in:
kolaente 2021-03-10 14:04:15 +01:00
parent 16b2e14841
commit 04e88be8ce
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
6 changed files with 1187 additions and 835 deletions

View File

@ -5,7 +5,7 @@
"scripts": {
"serve": "npx vite preview",
"serve:dist": "node scripts/serve-dist.js",
"build": "npx vite build",
"build": "npx workbox copyLibraries dist/ && npx vite build",
"build:report": "vue-cli-service build --report",
"lint": "vue-cli-service lint --ignore-pattern '*.test.*'",
"cypress:open": "cypress open",
@ -30,7 +30,8 @@
"vue-easymde": "1.3.2",
"vue-shortkey": "3.1.7",
"vue-smooth-dnd": "0.8.1",
"vuex": "3.6.2"
"vuex": "3.6.2",
"workbox-precaching": "^6.1.1"
},
"devDependencies": {
"@fortawesome/fontawesome-svg-core": "1.2.34",
@ -55,13 +56,14 @@
"sass": "1.32.8",
"sass-loader": "10.1.1",
"vite": "2.0.2",
"vite-plugin-pwa": "0.5.3",
"vite-plugin-pwa": "0.5.6",
"vite-plugin-vue2": "1.2.1",
"vue-flatpickr-component": "8.1.6",
"vue-notification": "1.3.20",
"vue-router": "3.5.1",
"vue-template-compiler": "2.6.12",
"wait-on": "5.2.1"
"wait-on": "5.2.1",
"workbox-cli": "6.1.1"
},
"eslintConfig": {
"root": true,

View File

@ -3,7 +3,7 @@ const express = require('express')
const app = express()
const p = path.join(__dirname, '..', 'dist')
const port = 8080
const port = 8000
app.use(express.static(p))
// Handle urls set by the frontend

View File

@ -1,6 +1,12 @@
/* eslint-disable no-console */
/* eslint-disable no-undef */
importScripts( "/workbox-v6.1.1/workbox-sw.js");
workbox.setConfig({modulePathPrefix: "/workbox-v6.1.1"});
import { precacheAndRoute } from 'workbox-precaching'
precacheAndRoute(self.__WB_MANIFEST)
// Cache assets
workbox.routing.registerRoute(
// This regexp matches all files in precache-manifest

View File

@ -4,7 +4,7 @@ import {register} from 'register-service-worker'
import swEvents from './ServiceWorker/events'
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}sw.js`, {
register('/sw.js', {
ready() {
console.log('App is being served from cache by a service worker.')
},

View File

@ -7,9 +7,10 @@ module.exports = {
createVuePlugin(),
VitePWA({
strategies: 'injectManifest',
injectRegister: false,
injectManifest: {
importWorkboxFrom: 'local',
swSrc: './src/ServiceWorker/sw.js',
swDest: './dist/sw.js',
},
manifest: {
name: 'Vikunja',

1999
yarn.lock

File diff suppressed because it is too large Load Diff