Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

jasonjgardner/fresh_pwa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Don't use Fresh. Switch to aleph.js

Fresh turned into a sloppy framework. This project is no longer maintained.

Fresh PWA Plugin

Usage:

fresh.config.ts

import { defineConfig } from "$fresh/server.ts";
import PWAPlugin from "https://deno.land/x/fresh_pwa/mod.ts";

export default defineConfig({
  plugins: [
    PWAPlugin({
      // Web app manifest
      manifest: {
        name: "Fresh PWA",
        short_name: "Fresh",
        description: "Fresh PWA example",
        icons: [
          {
            src: "/logo.svg",
            type: "image/svg+xml",
            sizes: "48x48",
          },
        ],
        id: "/?source=pwa",
        start_url: "/?source=pwa",
        background_color: "#86efac",
        display: "standalone",
        scope: "/",
        theme_color: "#86efac",
        shortcuts: [],
      },
      // Worker source URL
      swSrc: new URL("./src/sw.ts", import.meta.url),
      compilerOptions: {
        // SWC compiler option overrides
      },
    }),
  ],
});

routes/_app.tsx

import { AppProps } from "$fresh/server.ts";

export default function App({ Component }: AppProps) {
  return (
    <html>
      <head>
+       <link href="/app.webmanifest" rel="manifest" />
      </head>
    </html>
  );
}

deno.json

{
  "tasks": {
-    "start": "deno run -A --watch=static/,routes/ dev.ts",
+    "start": "deno run -A --watch=static/,routes/,src/ dev.ts",
  }
}

Create src/sw.ts

self.addEventListener("install", event => {
  // etc.
});