Skip to content

Commit f25d783

Browse files
committed
add pwa
1 parent 656d29f commit f25d783

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
FROM node:lts
22

3-
RUN apk add --no-cache libc6-compat
4-
53
COPY ./ ./
64

75
RUN yarn install && npx next build

next.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const withPWA = require('next-pwa')
2-
const runtimeCaching = require('next-pwa/cache')
32

43
module.exports = withPWA({
54
pwa: {
65
dest: 'public',
7-
runtimeCaching,
6+
register: true,
7+
skipWaiting: true,
88
},
99
})

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"highlight.js": "11.5.1",
1616
"markdown-it": "12.3.2",
1717
"moment": "2.29.2",
18-
"next": "12.1.2",
19-
"next-pwa": "5.4.1",
18+
"next": "12.1.4",
19+
"next-pwa": "5.5.0",
2020
"nprogress": "0.2.0",
2121
"react": "18.0.0",
2222
"react-dom": "18.0.0",

pages/_app.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import NProgress from "nprogress";
33
import '../styles/globals.css';
44
import '../css/nprogress.css';
55
import {useRouter} from "next/router";
6-
import Head from 'next/head';
7-
86

97
function MyApp({Component, pageProps}) {
108
const router = useRouter();
@@ -21,36 +19,7 @@ function MyApp({Component, pageProps}) {
2119
});
2220
}, []);
2321

24-
return <>
25-
<Head>
26-
<meta charSet="utf-8"/>
27-
<meta httpEquiv="X-UA-Compatible" content="IE=edge"/>
28-
<meta
29-
name="viewport"
30-
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
31-
/>
32-
<meta name="description" content="Description"/>
33-
<meta name="keywords" content="Keywords"/>
34-
<title>Next.js PWA Example</title>
35-
36-
<link rel="manifest" href="/manifest.json"/>
37-
<link
38-
href="/icons/icon-16x16.png"
39-
rel="icon"
40-
type="image/png"
41-
sizes="16x16"
42-
/>
43-
<link
44-
href="/icons/icon-32x32.png"
45-
rel="icon"
46-
type="image/png"
47-
sizes="32x32"
48-
/>
49-
<link rel="apple-touch-icon" href="/icons/icon-512x512.png"/>
50-
<meta name="theme-color" content="#317EFB"/>
51-
</Head>
52-
<Component {...pageProps} />
53-
</>
22+
return <Component {...pageProps} />
5423
}
5524

5625
export default MyApp

pages/_document.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Document, {Head, Html, Main, NextScript} from "next/document";
2+
3+
class MyDocument extends Document {
4+
render() {
5+
return (
6+
<Html>
7+
<Head>
8+
<link rel="manifest" href="/manifest.json"/>
9+
<link rel="apple-touch-icon" href="/icons/icon-96x96.png"></link>
10+
<meta name="theme-color" content="#fff"/>
11+
</Head>
12+
<body>
13+
<Main/>
14+
<NextScript/>
15+
</body>
16+
</Html>
17+
);
18+
}
19+
}
20+
21+
export default MyDocument;

0 commit comments

Comments
 (0)