provides the @islands/pwa module, created by @userquin, which will add and configure vite-plugin-pwa to make your website work offline.
import { defineConfig } from 'iles'
import pwa from '@islands/pwa'
export default defineConfig({
modules: [
pwa(options),
],
})
By default, it will use the generateSW strategy, and it will prompt for updates.
When using generateSW with prompt
:
registerSW.js
won't be generated unless explicitly enabledWhen using generateSW with autoUpdate
:
clientsClaim
and skipWaiting
will be enabledregisterSW.js
won't be generated unless explicitly enabledprompt
for updatesWhen using the generateSW strategy with prompt
, you
should register the service worker using a client script block in a component
that is rendered in every page of your site (included in every layout).
See the PWA configuration for this website, which uses a dialog component to display a prompt to update the site.
autoUpdate
When using the generateSW strategy with autoUpdate
,
you should register the service worker using a client script block in a component
that is rendered in every page of your site (included in every layout).
<script client:load lang="ts">
import { registerSW } from 'virtual:pwa-register'
registerSW({ immediate: true })
</script>
Don't specify the Vite plugin manuallyYou should provide any configuration for vite-plugin-pwa in the @islands/pwa module.