Developing Electron Apps

Misc

Configuring PWA

We’ll be using Quasar CLI to develop and build a PWA. The difference between building a SPA, Mobile App, Electron App, PWA or SSR is simply determined by the “mode” parameter in “quasar dev” and “quasar build” commands.

Installation

In order to build a PWA, we first need to add the PWA mode to our Quasar project:

$ quasar mode -a pwa

If you want to jump right in and start developing, you can skip the “quasar mode” command and issue:

$ quasar dev -m pwa

This will add PWA mode automatically, if it is missing.

Service Worker

Adding PWA mode to a Quasar project means a new folder will be created: /src-pwa, which contains PWA specific files:

“register-service-worker.js” is automatically imported into your app (like any other /src file). It registers the service worker (created by Workbox or your custom one, depending on workbox plugin mode – quasar.conf.js > pwa > workboxPluginMode) and you can listen for Service Worker’s events. You can use ES6 code.

“custom-service-worker.js” will be your service worker file ONLY if workbox plugin mode is set to “InjectManifest” (quasar.conf.js > pwa > workboxPluginMode: ‘InjectManifest’). Otherwise, Workbox will create a service-worker file for you.

It makes sense to run Lighthouse tests on production builds only.

Quasar.conf.js

This is the place where you can configure Workbox’s behavior and also tweak your manifest.json.