From ed3ab8f8deaff320999ff32deeb8d4aad9c81f10 Mon Sep 17 00:00:00 2001 From: Jack Hanford Date: Thu, 23 Aug 2018 16:12:22 -0700 Subject: [PATCH] restore offline (#486) * restore offline * move service-worker.js file to /public * don't inclue withOffline during dev * bump next-offline --- next.config.js | 14 ++++++++----- package.json | 2 +- yarn.lock | 54 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/next.config.js b/next.config.js index 9b61716..cd6ced8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,9 +1,9 @@ -// const { PHASE_DEVELOPMENT_SERVER } = require('next/constants') -// const withOffline = require('next-offline') +const { PHASE_DEVELOPMENT_SERVER } = require('next/constants') +const withOffline = require('next-offline') -module.exports = (/* phase, { defaultConfig } */) => { +module.exports = (phase /* { defaultConfig } */) => { const config = { - exportPathMap() { + async exportPathMap() { return { '/about': { page: '/about' }, '/embed': { page: '/embed' }, @@ -19,5 +19,9 @@ module.exports = (/* phase, { defaultConfig } */) => { } } - return config + if (phase === PHASE_DEVELOPMENT_SERVER) { + return config + } + + return withOffline(config) } diff --git a/package.json b/package.json index 609ee8e..44c3d83 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "morphmorph": "^0.1.0", "ms": "^2.0.0", "next": "^6.0.3", - "next-offline": "^2.9.0", + "next-offline": "^2.10.1", "prettier": "^1.8.1", "react": "16.3.*", "react-addons-shallow-compare": "^15.6.2", diff --git a/yarn.lock b/yarn.lock index c5df462..7da599e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -919,7 +919,7 @@ array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" -arrify@^1.0.0: +arrify@^1.0.0, arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -1234,7 +1234,7 @@ builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" -cacache@^10.0.1: +cacache@^10.0.1, cacache@^10.0.4: version "10.0.4" resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460" dependencies: @@ -1583,6 +1583,19 @@ copy-to-clipboard@^3: dependencies: toggle-selection "^1.0.3" +copy-webpack-plugin@~4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.5.2.tgz#d53444a8fea2912d806e78937390ddd7e632ee5c" + dependencies: + cacache "^10.0.4" + find-cache-dir "^1.0.0" + globby "^7.1.1" + is-glob "^4.0.0" + loader-utils "^1.1.0" + minimatch "^3.0.4" + p-limit "^1.0.0" + serialize-javascript "^1.4.0" + core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" @@ -1864,6 +1877,13 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +dir-glob@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034" + dependencies: + arrify "^1.0.1" + path-type "^3.0.0" + dnd-core@^4.0.5: version "4.0.5" resolved "https://registry.yarnpkg.com/dnd-core/-/dnd-core-4.0.5.tgz#3b83d138d0d5e265c73ec978dec5e1ed441dc665" @@ -2732,6 +2752,17 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" +globby@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/globby/-/globby-7.1.1.tgz#fb2ccff9401f8600945dfada97440cca972b8680" + dependencies: + array-union "^1.0.1" + dir-glob "^2.0.0" + glob "^7.1.2" + ignore "^3.3.5" + pify "^3.0.0" + slash "^1.0.0" + graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -2992,6 +3023,10 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" +ignore@^3.3.5: + version "3.3.10" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" + ignore@^4.0.2: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -4000,10 +4035,11 @@ neo-async@^2.5.0: version "2.5.2" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.5.2.tgz#489105ce7bc54e709d736b195f82135048c50fcc" -next-offline@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/next-offline/-/next-offline-2.9.0.tgz#53c3af19dc4b502a02f7b534f951cc8e98c2ae97" +next-offline@^2.10.1: + version "2.10.1" + resolved "https://registry.yarnpkg.com/next-offline/-/next-offline-2.10.1.tgz#561bafd8657a48cda8f65fcb9fa771154f98e95c" dependencies: + copy-webpack-plugin "~4.5.2" fs-extra "~5.0.0" glob "~7.0.0" minimist "1.2.0" @@ -4343,7 +4379,7 @@ p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" -p-limit@^1.1.0: +p-limit@^1.0.0, p-limit@^1.1.0: version "1.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" dependencies: @@ -4455,6 +4491,12 @@ path-type@^2.0.0: dependencies: pify "^2.0.0" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + dependencies: + pify "^3.0.0" + pbkdf2@^3.0.3: version "3.0.16" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.16.tgz#7404208ec6b01b62d85bf83853a8064f8d9c2a5c"