Skip to content

Commit

Permalink
pwa
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffSpies committed Sep 2, 2021
1 parent 1fe265a commit 0201ef5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "eslint --ext .js,.vue src",
"test": "echo \"No test specified\" && exit 0",
"build": "quasar build",
"build-ssr": "quasar build -m ssr"
"build-ssr": "quasar build -m ssr",
"build-pwa": "quasar build -m pwa"
},
"dependencies": {
"@quasar/extras": "^1.10.10",
Expand Down
5 changes: 5 additions & 0 deletions client/src-pwa/custom-service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* This file (which will be your service worker)
* is picked up by the build system ONLY if
* quasar.conf > pwa > workboxPluginMode is set to "InjectManifest"
*/
9 changes: 9 additions & 0 deletions client/src-pwa/pwa-flag.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
import "quasar/dist/types/feature-flag";

declare module "quasar/dist/types/feature-flag" {
interface QuasarFeatureFlags {
pwa: true;
}
}
41 changes: 41 additions & 0 deletions client/src-pwa/register-service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { register } from 'register-service-worker'

// The ready(), registered(), cached(), updatefound() and updated()
// events passes a ServiceWorkerRegistration instance in their arguments.
// ServiceWorkerRegistration: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration

register(process.env.SERVICE_WORKER_FILE, {
// The registrationOptions object will be passed as the second argument
// to ServiceWorkerContainer.register()
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#Parameter

// registrationOptions: { scope: './' },

ready (/* registration */) {
// console.log('Service worker is active.')
},

registered (/* registration */) {
// console.log('Service worker has been registered.')
},

cached (/* registration */) {
// console.log('Content has been cached for offline use.')
},

updatefound (/* registration */) {
// console.log('New content is downloading.')
},

updated (/* registration */) {
// console.log('New content is available; please refresh.')
},

offline () {
// console.log('No internet connection found. App is running in offline mode.')
},

error (/* err */) {
// console.error('Error during service worker registration:', err)
}
})

0 comments on commit 0201ef5

Please sign in to comment.