Skip to content

Commit 051ffe5

Browse files
committed
feat: ✨ add PWA support
1 parent 78de66a commit 051ffe5

File tree

9 files changed

+116
-10
lines changed

9 files changed

+116
-10
lines changed

.github/actions/install/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
- name: 🏗 Setup bun
88
uses: oven-sh/setup-bun@v1
99
with:
10-
bun-version: 1.1.14
10+
bun-version: 1.1.16
1111

1212
- name: 🏗 Setup bun cache
1313
uses: actions/cache@v4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- 🍞 [bun][bun] for a fast runtime and package manager.
88
- ⚡️ [vite][vite] for instant server start and lighting fast HMR.
9+
-[Vite PWA](https://vite-pwa-org.netlify.app) for PWAs with very little configuration.
910
- 🏷️ [TypeScript][TypeScript] for a less frustrating & consistent experience.
1011
- 🏝️ [TanStack Router][TanStack Router] for a fully type-safe React router.
1112
- 🏝️ [TanStack Query][TanStack Query] for asynchronous state management.

bun.lockb

43.3 KB
Binary file not shown.

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
"prettier": "@jimmy.codes/prettier-config",
2525
"dependencies": {
2626
"@tanstack/react-query": "5.45.1",
27-
"@tanstack/react-router": "1.39.4",
27+
"@tanstack/react-router": "1.40.0",
2828
"clsx": "2.1.1",
2929
"react": "18.3.1",
3030
"react-dom": "18.3.1",
3131
"tailwind-merge": "2.3.0"
3232
},
3333
"devDependencies": {
3434
"@iconify-json/logos": "1.1.43",
35-
"@iconify-json/lucide": "1.1.193",
35+
"@iconify-json/lucide": "1.1.194",
3636
"@iconify/tailwind": "1.1.1",
3737
"@jimmy.codes/eslint-config": "1.9.0",
3838
"@jimmy.codes/prettier-config": "1.1.0",
@@ -48,34 +48,36 @@
4848
"@storybook/test": "8.1.10",
4949
"@tailwindcss/typography": "0.5.13",
5050
"@tanstack/react-query-devtools": "5.45.1",
51-
"@tanstack/router-devtools": "1.39.4",
52-
"@tanstack/router-vite-plugin": "1.39.5",
51+
"@tanstack/router-devtools": "1.40.0",
52+
"@tanstack/router-vite-plugin": "1.39.13",
5353
"@testing-library/dom": "10.1.0",
5454
"@testing-library/jest-dom": "6.4.6",
5555
"@testing-library/react": "16.0.0",
5656
"@testing-library/user-event": "14.5.2",
5757
"@total-typescript/ts-reset": "0.5.1",
58-
"@types/bun": "1.1.4",
58+
"@types/bun": "1.1.5",
5959
"@types/react": "18.3.3",
6060
"@types/react-dom": "18.3.0",
61+
"@vite-pwa/assets-generator": "0.2.4",
6162
"@vitejs/plugin-react-swc": "3.7.0",
6263
"@vitest/coverage-v8": "1.6.0",
6364
"@vitest/ui": "1.6.0",
6465
"autoprefixer": "10.4.19",
65-
"daisyui": "4.12.2",
66+
"daisyui": "4.12.6",
6667
"eslint": "8.57.0",
6768
"eslint-plugin-storybook": "0.8.0",
6869
"gitzy": "5.4.0",
69-
"happy-dom": "14.12.0",
70+
"happy-dom": "14.12.3",
7071
"is-ci": "3.0.1",
71-
"lefthook": "1.6.16",
72+
"lefthook": "1.6.18",
7273
"msw": "2.3.1",
7374
"postcss": "8.4.38",
7475
"prettier": "3.3.2",
7576
"storybook": "8.1.10",
7677
"tailwindcss": "3.4.4",
7778
"typescript": "5.4.5",
7879
"vite": "5.3.1",
80+
"vite-plugin-pwa": "0.20.0",
7981
"vite-tsconfig-paths": "4.3.2",
8082
"vitest": "1.6.0"
8183
}

public/favicon.ico

-15 KB
Binary file not shown.

public/logo.svg

Lines changed: 34 additions & 0 deletions
Loading

pwa-assets.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {
2+
defineConfig,
3+
minimal2023Preset as preset,
4+
} from "@vite-pwa/assets-generator/config";
5+
6+
export default defineConfig({
7+
headLinkOptions: {
8+
preset: "2023",
9+
},
10+
preset,
11+
images: ["public/logo.svg"],
12+
});

src/pages/home.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// eslint-disable-next-line import-x/no-unresolved, import-x/no-absolute-path
2+
import logo from "/logo.svg";
13
import { ExtLink } from "@/components/ext-link";
24

35
export const Home = () => {
@@ -17,7 +19,8 @@ export const Home = () => {
1719
React Starter
1820
</h1>
1921
<p className="prose dsy-prose py-6">
20-
🍱 Another <ExtLink to="React">React</ExtLink> Starter using{" "}
22+
<img src={logo} alt="logo" className="not-prose inline max-h-6" />{" "}
23+
Another <ExtLink to="React">React</ExtLink> Starter using{" "}
2124
<ExtLink to="Bun">Bun</ExtLink>, <ExtLink to="Vite">Vite</ExtLink>
2225
, <ExtLink to="TypeScript">TypeScript</ExtLink>,{" "}
2326
<ExtLink to="tailwindcss">tailwindcss</ExtLink> and{" "}

vite.config.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { TanStackRouterVite as tanStackRouterVite } from "@tanstack/router-vite-plugin";
22
import react from "@vitejs/plugin-react-swc";
33
import { defineConfig, loadEnv } from "vite";
4+
import { VitePWA } from "vite-plugin-pwa";
45
import tsconfigPaths from "vite-tsconfig-paths";
56
import { configDefaults } from "vitest/config";
67

@@ -19,6 +20,59 @@ export default defineConfig(({ mode }) => {
1920
},
2021
}),
2122
tsconfigPaths(),
23+
VitePWA({
24+
strategies: "generateSW",
25+
registerType: "prompt",
26+
injectRegister: false,
27+
pwaAssets: {
28+
disabled: false,
29+
config: true,
30+
htmlPreset: "2023",
31+
overrideManifestIcons: true,
32+
},
33+
manifest: {
34+
name: "React Starter",
35+
short_name: "React Starter",
36+
theme_color: "#ffffff",
37+
icons: [
38+
{
39+
src: "pwa-64x64.png",
40+
sizes: "64x64",
41+
type: "image/png",
42+
},
43+
{
44+
src: "pwa-192x192.png",
45+
sizes: "192x192",
46+
type: "image/png",
47+
},
48+
{
49+
src: "pwa-512x512.png",
50+
sizes: "512x512",
51+
type: "image/png",
52+
},
53+
{
54+
src: "maskable-icon-512x512.png",
55+
sizes: "512x512",
56+
type: "image/png",
57+
purpose: "maskable",
58+
},
59+
],
60+
},
61+
workbox: {
62+
globPatterns: ["**/*.{js,css,html,svg,png,svg,ico}"],
63+
cleanupOutdatedCaches: true,
64+
clientsClaim: true,
65+
},
66+
injectManifest: {
67+
globPatterns: ["**/*.{js,css,html,svg,png,svg,ico}"],
68+
},
69+
devOptions: {
70+
enabled: false,
71+
navigateFallback: "index.html",
72+
suppressWarnings: true,
73+
type: "module",
74+
},
75+
}),
2276
],
2377
server: {
2478
port: Number(PORT),

0 commit comments

Comments
 (0)