From a5f17d7e7a1e7132a87d7fc0faf59815059fa251 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 21 Nov 2023 10:11:34 +0700 Subject: Add PWA --- .gitignore | 4 ++++ next.config.js | 14 ++++++++++++-- package.json | 1 + public/manifest.json | 12 ++++++++++++ src/app/layout.tsx | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 public/manifest.json diff --git a/.gitignore b/.gitignore index 45c1abc..6abf28c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +sw.* +workbox-* +swe-worker-* \ No newline at end of file diff --git a/next.config.js b/next.config.js index 767719f..cb8597e 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,14 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {} +const withPWA = require("@ducanh2912/next-pwa").default({ + dest: "public", + cacheOnFrontEndNav: true, + aggressiveFrontEndNavCaching: true, + reloadOnOnline: true, + swcMinify: true, + disable: process.env.NODE_ENV === "development", + workboxOptions: { disableDevLogs: true }, +}); -module.exports = nextConfig +const nextConfig = {}; + +module.exports = withPWA(nextConfig); diff --git a/package.json b/package.json index 1ab9e0e..3cf6f22 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint": "next lint" }, "dependencies": { + "@ducanh2912/next-pwa": "^9.7.2", "@nextui-org/react": "^2.1.13", "@prisma/client": "^5.5.2", "@tanstack/react-query": "^5.4.3", diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..2163947 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "FIN Stock Opname", + "short_name": "FIN Stock Opname", + "description": "FIN Stock Opname", + "icons": [], + "theme_color": "#FFFFFF", + "background_color": "#FFFFFF", + "start_url": "/", + "scope": ".", + "display": "standalone", + "orientation": "portrait" +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 933e308..33884a6 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -7,6 +7,7 @@ import QueryProvider from '@/common/contexts/QueryProvider' import { Toaster } from 'react-hot-toast' export const metadata: Metadata = { + manifest: '/manifest.json', title: 'FIN Stock Opname', description: 'FIN Stock Opname', viewport: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0', -- cgit v1.2.3