Skip to content

Commit

Permalink
Reimplements next-offline - see hanford/next-offline#90
Browse files Browse the repository at this point in the history
  • Loading branch information
4cm4k1 committed Dec 2, 2018
1 parent 711f5f6 commit a4bc001
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.9.2

- Reimplements [`next-offline`](https://github.com/hanford/next-offline), sans `static/**/*` assets, which will be cached at runtime (see [discussion](https://github.com/hanford/next-offline/issues/90))

## 0.9.1

- Updates [`readme.md`](readme.md) and other Markdown files
Expand Down
27 changes: 25 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ const nextConfig = {
},
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => config,
webpackDevMiddleware: config => config,
workboxOpts: {
swDest: 'static/service-worker.js',
runtimeCaching: [
{
urlPattern: /^https?.*/,
handler: 'networkFirst',
options: {
cacheName: 'https-calls',
networkTimeoutSeconds: 15,
expiration: {
maxEntries: 150,
maxAgeSeconds: 30 * 24 * 60 * 60, // 1 month
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
};

const sassConfig = {
Expand Down Expand Up @@ -90,8 +110,11 @@ module.exports = moduleExists('next-compose-plugins')
optional(() => require('@zeit/next-mdx')()),
[PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD],
],
// next-offline - for now omit until Now v2 compatibility is sorted
[optional(() => require('next-offline')), [PHASE_EXPORT]],
// next-offline
[
optional(() => require('next-offline')),
[PHASE_EXPORT, PHASE_PRODUCTION_BUILD],
],
// @zeit/next-source-maps
[
optional(() => require('@zeit/next-source-maps')()),
Expand Down
4 changes: 4 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
},
"dest": "/static/$1.$2"
},
{
"src": "^/service-worker.js$",
"dest": "/_next/static/service-worker.js"
},
{
"src": "/_next/static/.*",
"headers": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "website",
"version": "0.9.1",
"version": "0.9.2",
"private": true,
"description": "Personal site built with React, Next.js, and Material Components",
"bugs": "https://github.com/4cm4k1/website/issues",
Expand Down Expand Up @@ -61,7 +61,7 @@
"husky": "^1.2.0",
"modern-normalize": "^0.5.0",
"next-compose-plugins": "^2.1.1",
"next-offline": "^3.2.1",
"next-offline": "^3.2.2",
"next-purgecss": "^3.0.0",
"npm-run-all": "^4.1.5",
"optimize-css-assets-webpack-plugin": "^5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5189,7 +5189,7 @@ next-compose-plugins@^2.1.1:
resolved "https://registry.yarnpkg.com/next-compose-plugins/-/next-compose-plugins-2.1.1.tgz#7da0a3ce0c8ce267b5cb4164d2fb6e4aaf61bf86"
integrity sha512-4yLtmGjnBlzuYdL66+c/zi8ljl24sK9jtP31UsTG1ZAAHj+ybWfEG/S+HMwK+pD2fNmJ4xQyr4xOubzExcS+Lg==

next-offline@^3.2.1:
next-offline@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/next-offline/-/next-offline-3.2.2.tgz#6ac416c98287120a296a6f681f083e99155c23b4"
integrity sha512-RCobLztadsQWkpcgxvSDJXOcrQLnhPyCV/63mAmz7r9Tea4Ezjv7zq8HJ1EC3n3CCppcHMmONS+1H4TbA02ByQ==
Expand Down

1 comment on commit a4bc001

@vercel
Copy link

@vercel vercel bot commented on a4bc001 Dec 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully aliased the URL https://anthony-codes-lvb2c5fry.now.sh to the following alias.

Please sign in to comment.