Skip to content

Commit 64b22b5

Browse files
author
Luis Doebbel
committed
feature: adds config for service worker and pwa assets config
1 parent f773571 commit 64b22b5

5 files changed

Lines changed: 2020 additions & 24 deletions

File tree

frontend/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
65
<meta name="viewport" content="initial-scale=1, width=device-width" />
76
<meta name="theme-color" content="#000000" />
87
<!-- Fonts to support Material Design -->

frontend/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@types/sass": "^1.45.0",
4747
"@typescript-eslint/eslint-plugin": "^7.13.1",
4848
"@typescript-eslint/parser": "^7.13.1",
49+
"@vite-pwa/assets-generator": "^0.2.4",
4950
"@vitejs/plugin-react": "^4.3.1",
5051
"eclint": "^2.8.1",
5152
"eslint": "^8.57.0",
@@ -63,6 +64,11 @@
6364
"stylelint-prettier": "^5.0.0",
6465
"stylelint-scss": "^6.3.2",
6566
"typescript": "^5.2.2",
66-
"vite": "^5.3.1"
67+
"vite": "^5.3.1",
68+
"vite-plugin-pwa": "^0.20.0"
69+
},
70+
"resolutions": {
71+
"sharp": "0.32.6",
72+
"sharp-ico": "0.1.5"
6773
}
6874
}

frontend/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/vite.svg"],
12+
});

frontend/vite.config.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
import { defineConfig, loadEnv } from "vite";
2+
import { VitePWA } from "vite-plugin-pwa";
23
import react from "@vitejs/plugin-react";
34
import path from "path";
45

56
export default ({ mode }: { mode: string }) => {
67
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
78

89
return defineConfig({
9-
plugins: [react()],
10+
plugins: [
11+
react(),
12+
VitePWA({
13+
registerType: "autoUpdate",
14+
injectRegister: false,
15+
16+
pwaAssets: {
17+
disabled: false,
18+
config: true,
19+
},
20+
21+
manifest: {
22+
name: "react-template-demo",
23+
short_name: "react-template-demo",
24+
description: "Nventive React Template Demo",
25+
theme_color: "#ffffff",
26+
},
27+
28+
workbox: {
29+
globPatterns: ["**/*.{js,css,html,svg,png,ico}"],
30+
cleanupOutdatedCaches: true,
31+
clientsClaim: true,
32+
},
33+
34+
devOptions: {
35+
enabled: true,
36+
navigateFallback: "index.html",
37+
suppressWarnings: true,
38+
type: "module",
39+
},
40+
}),
41+
],
1042
css: {
1143
preprocessorOptions: {
1244
scss: {

0 commit comments

Comments
 (0)