PWA

Introduction

This feature integrated

@vite-pwa/sveltekit

Pass pwa option to theme default to use pwa. The options are exactly the same as

SvelteKit PWA Plugin Options
except for darkManifest, which is the manifest path that would used for dark theme

And the svelte.config.js need to config files.serviceWorker, use the SERVICE_WORKER_PATH exported from @sveltepress/theme-default

svelte.config.js
+
+
+
+
import {  } from '@sveltejs/vite-plugin-svelte'
import  from '@sveltejs/adapter-static'

import {  } from '@sveltepress/theme-default' 

/** @type {import('@sveltejs/kit').Config} */
const  = {
  : ['.svelte', '.md'],
  : [()],
  : {
    : (),
    : { 
      : , 
    }, 
  },
}

export default 
ts
package required

If you want to enable pwa.
You will need to add workbox-window as a dev dependency to your Vite project.

Example config

Take the config this site use for example:

export default {
  : '/',
  : '/',
  : 'injectManifest',
  : {
    : 'always',
  },
  : '/manifest-dark.webmanifest',
  : {
    : '/',
    : '/',
    : 'Sveltepress',
    : 'Sveltepress',
    : [
      {
        : '/android-chrome-192x192.png',
        : '192x192',
        : 'image/png',
      },
      {
        : '/android-chrome-512x512.png',
        : '512x512',
        : 'image/png',
      },
    ],
    : '#f2f2f2',
    : '#f2f2f2',
    : 'standalone',
  },
} as any
ts
Last update at: 2024/03/19 06:32:39