Skip to content

Commit

Permalink
feat: add next-pwa / workbox
Browse files Browse the repository at this point in the history
  • Loading branch information
NPC64927130 committed Mar 20, 2022
1 parent f671a11 commit 19ee9f3
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ yarn-error.log*

# vercel
.vercel

# workbox
public/workbox-*.js*
public/sw.js*
public/worker-*.js*
9 changes: 6 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const withPlugins = require('next-compose-plugins');
const withPWA = require('next-pwa');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});

const plugins = [withBundleAnalyzer];
const nextPlugins = [withBundleAnalyzer, withPWA];

const nextConfig = {
swcMinify: true,
compiler: {
// ssr and displayName are configured by default
styledComponents: true,
},
pwa: {
dest: 'public',
},
};

module.exports = withPlugins(plugins, nextConfig);
module.exports = withPlugins(nextPlugins, nextConfig);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"focus-visible": "^5.2.0",
"next": "12.1.0",
"next-compose-plugins": "^2.2.1",
"next-pwa": "^5.4.6",
"normalize.css": "^8.0.1",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
26 changes: 26 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Money printer go BRRR",
"short_name": "BRRR.money",
"description": "Print it, baby!",
"start_url": "/",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#FFFFFF",
"icons": [
{
"src": "/icons/favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "/icons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
2 changes: 1 addition & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
User-agent: *
Disallow:
Disallow:
26 changes: 0 additions & 26 deletions public/site.webmanifest

This file was deleted.

12 changes: 10 additions & 2 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class App extends NextApp {
<meta name="description" content={description} />
<meta name="author" content={author} />
<link rel="canonical" href={url} />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no, user-scalable=no, viewport-fit=cover"
/>
{/* Open Graph */}
<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
Expand All @@ -79,6 +82,11 @@ class App extends NextApp {
})}
{/* Safari */}
<meta name="apple-mobile-web-app-title" content={title} />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="default"
/>
<link
rel="apple-touch-icon"
sizes="300x300"
Expand All @@ -92,7 +100,7 @@ class App extends NextApp {
{/* Windows */}
<meta name="msapplication-config" content="/browserconfig..xml" />
{/* PWA manifest */}
<link rel="manifest" href="/site.webmanifest" />
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content={brandColor} />
</Head>
<GlobalStyle />
Expand Down

0 comments on commit 19ee9f3

Please sign in to comment.