Don't use Fresh. Switch to aleph.js
Fresh turned into a sloppy framework. This project is no longer maintained.
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.
});