Skip to content

Commit

Permalink
fixed pwa build
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelgeek committed Oct 15, 2024
1 parent 1243626 commit 4b174f1
Show file tree
Hide file tree
Showing 3 changed files with 2,890 additions and 2,334 deletions.
181 changes: 91 additions & 90 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,108 @@
/** @type {import('next').NextConfig} */
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withPWA = require('next-pwa')

module.exports = withPWA({
reactStrictMode: true,
pwa: {
dest: 'public',
register: true,
// swSrc: 'service-worker.js',
skipWaiting: true,
cacheOnFrontEndNav: true,
disable: process.env.NODE_ENV === 'development',
runtimeCaching: [
{
urlPattern: '/^https://fonts.googleapis.com/.*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-font-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
const withPWA = require('next-pwa', {
dest: 'public',
register: true,
swSrc: 'service-worker.js',
skipWaiting: true,
cacheOnFrontEndNav: true,
disable: process.env.NODE_ENV === 'development',
runtimeCaching: [
{
urlPattern: '/^https://fonts.googleapis.com/.*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-font-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: /\.(?:mp4|webp)$/i,
handler: 'CacheFirst',
options: {
cacheName: 'static-video-assets',
expiration: {
maxEntries: 64,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: /\.(?:mp4|webp)$/i,
handler: 'CacheFirst',
options: {
cacheName: 'static-video-assets',
expiration: {
maxEntries: 64,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
},
},
{
urlPattern: '/^https://via.placeholder.com/*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-image-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
},
{
urlPattern: '/^https://via.placeholder.com/*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-image-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: '/^https://res.cloudinary.com/droidconke/*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-image-assets-1',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: '/^https://res.cloudinary.com/droidconke/*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-image-assets-1',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: '/^https://sessionize.com/image*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-img-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: '/^https://sessionize.com/image*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-img-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: '/^https://lh3.googleusercontent.com/*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-images-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: '/^https://lh3.googleusercontent.com/*/i',
handler: 'CacheFirst',
options: {
cacheName: 'static-images-assets',
expiration: {
maxEntries: 4,
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: `/^${process.env.NEXT_PUBLIC_API_BASE_URL}/*/i`,
handler: 'NetworkFirst',
// handler: 'StaleWhileRevalidate',
// method: 'GET',
options: {
// cacheableResponse: { statuses: [0, 200, 201] },
cacheName: 'api-data-sets-1',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 7, // 7 days
},
// method: 'GET',
// strategyOptions: { cacheableResponse: { statuses: [0, 200] } },
},
{
urlPattern: `/^${process.env.NEXT_PUBLIC_API_BASE_URL}/*/i`,
handler: 'NetworkFirst',
// handler: 'StaleWhileRevalidate',
// method: 'GET',
options: {
// cacheableResponse: { statuses: [0, 200, 201] },
cacheName: 'api-data-sets-1',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 7, // 7 days
},
},
],
},
},
],
})

const nextConfig = {
reactStrictMode: true,
}

module.exports = [nextConfig, withPWA]
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@
"engines": {
"node": ">=16.x",
"npm": ">=8.x"
},
"packageManager": "[email protected]+sha512.af78262d7d125afbfeed740602ace8c5e4405cd7f4735c08feb327286b2fdb2390fbca01589bfd1f50b1240548b74806767f5a063c94b67e431aabd0d86f7774"
}
}
Loading

0 comments on commit 4b174f1

Please sign in to comment.