Skip to content

Commit 8fbcd66

Browse files
committed
try pwa
1 parent bb542a9 commit 8fbcd66

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lerna-debug.log*
1010
node_modules
1111
dist
1212
dist-ssr
13+
dev-dist
1314
*.local
1415

1516
# Editor directories and files

src/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const NotFound = lazy(() => import("./NotFound"));
1010

1111
render(
1212
() => (
13-
<div className="max-w-700px m-auto mt-8rem mb-8rem pl-1rem pr-1rem">
13+
<div className="max-w-42rem m-auto mt-6.75rem mb-8rem pl-1.25rem pr-1.25rem">
1414
<Router source={hashIntegration()}>
1515
<Routes>
1616
<Route path="/" component={App} />

vite.config.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,65 @@
11
import { defineConfig, splitVendorChunkPlugin } from "vite";
22
import solid from "vite-plugin-solid";
33
import UnoCSS from "unocss/vite";
4+
import { VitePWA } from "vite-plugin-pwa";
45
import getPostsPlugin from "./get-posts-plugin";
56

7+
import meta from "./src/meta.data";
8+
69
const cdn = (path) => `https://cdn.jsdelivr.net/npm/${path}`;
710

811
export default defineConfig({
9-
plugins: [solid(), UnoCSS(), getPostsPlugin(), splitVendorChunkPlugin()],
12+
plugins: [
13+
solid(),
14+
UnoCSS(),
15+
VitePWA({
16+
manifest: {
17+
name: meta.title,
18+
short_name: meta.title,
19+
description: meta.description,
20+
theme_color: "#ffffff",
21+
// icons: [
22+
// {
23+
// src: "icon-192x192.png",
24+
// sizes: "192x192",
25+
// type: "image/png",
26+
// },
27+
// {
28+
// src: "icon-512x512.png",
29+
// sizes: "512x512",
30+
// type: "image/png",
31+
// },
32+
// ],
33+
},
34+
registerType: "autoUpdate",
35+
workbox: {
36+
globPatterns: ["**/*.{js,css,html,ico,png,svg}"],
37+
runtimeCaching: [
38+
{
39+
urlPattern: /^https:\/\/cdn\.jsdelivr\.net\/\//i,
40+
handler: "CacheFirst",
41+
options: {
42+
cacheName: "jsdelivr-cdn",
43+
expiration: {
44+
maxEntries: 10,
45+
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
46+
},
47+
cacheableResponse: {
48+
statuses: [0, 200],
49+
},
50+
},
51+
},
52+
],
53+
},
54+
devOptions: {
55+
enabled: true,
56+
type: "module",
57+
navigateFallback: "index.html",
58+
},
59+
}),
60+
getPostsPlugin(),
61+
splitVendorChunkPlugin(),
62+
],
1063
esbuild: {
1164
pure: ["console.log"],
1265
},

0 commit comments

Comments
 (0)