Skip to content

Commit

Permalink
Merge pull request #377 from blinko-space/offline-support
Browse files Browse the repository at this point in the history
Offline support
  • Loading branch information
blinko-space authored Dec 26, 2024
2 parents aa036e0 + 80ccee7 commit c3890e7
Show file tree
Hide file tree
Showing 29 changed files with 762 additions and 264 deletions.
58 changes: 57 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,67 @@ const isProduction = process.env.NODE_ENV === 'production';
const isVercel = process.env.VERCEL === '1';
const withPWA = require('next-pwa')({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
register: true,
skipWaiting: true,
disable: false, // process.env.NODE_ENV === 'development',
fallbacks: {
document: '/offline'
},
cacheOnFrontEndNav: true,
reloadOnOnline: true,
runtimeCaching: [
{
urlPattern: ({ url, request }) => {
const isSameOrigin = self.origin === url.origin;
return isSameOrigin && (
request.destination === 'script' ||
url.pathname.includes('/_next/static/chunks/')
);
},
handler: 'NetworkFirst',
options: {
cacheName: 'js-cache',
networkTimeoutSeconds: 10,
expiration: {
maxEntries: 100,
maxAgeSeconds: 24 * 60 * 60
}
}
},
{
urlPattern: ({ url }) => url.pathname.startsWith('/api/'),
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
networkTimeoutSeconds: 10,
expiration: {
maxEntries: 50,
maxAgeSeconds: 24 * 60 * 60
}
}
},
{
urlPattern: ({ request }) =>
request.destination === 'style' ||
request.destination === 'script' ||
request.destination === 'font' ||
request.destination === 'image',
handler: 'CacheFirst',
options: {
cacheName: 'static-assets',
expiration: {
maxEntries: 100,
maxAgeSeconds: 24 * 60 * 60 * 30
}
}
}
]
})

module.exports = withPWA({
output: 'standalone',
transpilePackages: ['react-diff-view','highlight.js','remark-gfm','rehype-raw'],
pageExtensions: ['tsx', 'ts', 'jsx', 'js'],
async headers() {
return [
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"@types/react-grid-layout": "^1.3.2",
"@types/uuid": "^9.0.1",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.2.1",
"conventional-changelog-conventionalcommits": "^8.0.0",
"postcss": "^8.4.24",
"postcss-nesting": "^12.0.0",
Expand Down
111 changes: 111 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c3890e7

Please sign in to comment.