pickstack

Svelte + PWA

Installable app: manifest, icon and offline cache. This page shows exactly what pickstack adds to a Svelte project for PWA: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework svelte --modules pwa --yes
Customize in the configurator

Packages it adds

PackageVersionType
vite-plugin-pwa^2.0.0dev

New files

public/pwa-icon.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
  <title>my-app</title>
  <rect width="512" height="512" fill="#4f46e5" />
  <text
    x="256"
    y="256"
    fill="#ffffff"
    font-family="system-ui, sans-serif"
    font-size="280"
    font-weight="700"
    text-anchor="middle"
    dominant-baseline="central"
  >
    M
  </text>
</svg>

Changes to existing files

index.html (changed)
⋯ 3 unchanged lines     <meta charset="UTF-8" />     <meta name="viewport" content="width=device-width, initial-scale=1.0" />     <title>my-app</title>+    <meta name="theme-color" content="#4f46e5" />+    <link rel="icon" type="image/svg+xml" href="/pwa-icon.svg" />   </head>   <body>     <div id="app"></div>⋯ 4 unchanged lines
vite.config.ts (changed)
 import { svelte } from "@sveltejs/vite-plugin-svelte"; import { defineConfig } from "vite";+import { VitePWA } from "vite-plugin-pwa";   export default defineConfig({+  plugins: [+    svelte(),+    VitePWA({+      registerType: "autoUpdate",+      includeAssets: ["pwa-icon.svg"],+      manifest: {+        name: "my-app",+        short_name: "my-app",+        description: "my-app",+        theme_color: "#4f46e5",+        background_color: "#ffffff",+        icons: [+          {+            src: "pwa-icon.svg",+            sizes: "any",+            type: "image/svg+xml",+            purpose: "any",+          },+          {+            src: "pwa-icon.svg",+            sizes: "any",+            type: "image/svg+xml",+            purpose: "maskable",+          },+        ],+      },+    }),+  ],−  plugins: [svelte()], });  

Project files

Related templates