Skip to content

Commit badf653

Browse files
committed
fix: upgrade to zero config for zeit now
1 parent 0360fec commit badf653

File tree

5 files changed

+55
-90
lines changed

5 files changed

+55
-90
lines changed

next.config.js

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,61 @@
11
const withOffline = require("next-offline")
2-
const compose = require("next-compose")
32

4-
module.exports = compose([
5-
[
6-
withOffline,
7-
{
8-
target: "serverless",
9-
transformManifest: manifest => ["/"].concat(manifest), // add the homepage to the cache
10-
// Trying to set NODE_ENV=production when running yarn dev causes a build-time error so we
11-
// turn on the SW in dev mode so that we can actually test it
12-
generateInDevMode: true,
13-
workboxOpts: {
14-
swDest: process.env.NEXT_EXPORT ? "service-worker.js" : "static/service-worker.js",
15-
runtimeCaching: [
16-
{
17-
urlPattern: /^https?.*/,
18-
handler: "NetworkFirst",
19-
options: {
20-
cacheName: "https-calls",
21-
networkTimeoutSeconds: 15,
22-
expiration: {
23-
maxEntries: 150,
24-
maxAgeSeconds: 30 * 24 * 60 * 60 // 1 month
25-
},
26-
cacheableResponse: {
27-
statuses: [0, 200]
28-
}
29-
}
3+
const nextConfig = {
4+
transformManifest: manifest => ["/"].concat(manifest), // add the homepage to the cache
5+
// Trying to set NODE_ENV=production when running yarn dev causes a build-time error so we
6+
// turn on the SW in dev mode so that we can actually test it
7+
generateInDevMode: true,
8+
workboxOpts: {
9+
swDest: process.env.NEXT_EXPORT ? "service-worker.js" : "static/service-worker.js",
10+
runtimeCaching: [
11+
{
12+
urlPattern: /^https?.*/,
13+
handler: "NetworkFirst",
14+
options: {
15+
cacheName: "https-calls",
16+
networkTimeoutSeconds: 15,
17+
expiration: {
18+
maxEntries: 150,
19+
maxAgeSeconds: 30 * 24 * 60 * 60 // 1 month
3020
},
31-
{
32-
urlPattern: /.(?:png|webp|svg|mp4)$/,
33-
handler: "CacheFirst"
21+
cacheableResponse: {
22+
statuses: [0, 200]
3423
}
35-
]
24+
}
3625
},
37-
experimental: {
38-
async rewrites() {
39-
return [
26+
{
27+
urlPattern: /.(?:png|webp|svg|mp4)$/,
28+
handler: "CacheFirst"
29+
}
30+
]
31+
},
32+
experimental: {
33+
rewrites() {
34+
return [
35+
{
36+
source: "/service-worker.js",
37+
destination: "/_next/static/service-worker.js"
38+
}
39+
]
40+
},
41+
headers() {
42+
return [
43+
{
44+
source: "/service-worker.js",
45+
headers: [
4046
{
41-
source: "/service-worker.js",
42-
destination: "/_next/static/service-worker.js"
47+
key: "Cache-Control",
48+
value: "public, max-age=43200, immutable"
49+
},
50+
{
51+
key: "Service-Worker-Allowed",
52+
value: "/"
4353
}
4454
]
4555
}
46-
}
56+
]
4757
}
48-
]
49-
])
58+
}
59+
}
60+
61+
module.exports = withOffline(nextConfig)

now.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
11
{
22
"name": "noavoice",
3-
"version": 2,
4-
"routes": [
5-
{
6-
"src": "^/service-worker.js$",
7-
"dest": "/_next/static/service-worker.js",
8-
"headers": {
9-
"cache-control": "public, max-age=43200, immutable",
10-
"Service-Worker-Allowed": "/"
11-
}
12-
}
13-
],
14-
"builds": [
15-
{
16-
"src": "next.config.js",
17-
"use": "@now/next"
18-
}
19-
]
3+
"version": 2
204
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
"eslint-plugin-sort-imports-es6-autofix": "^0.5.0",
2020
"husky": "^4.2.1",
2121
"lint-staged": "^10.0.8",
22-
"next": "canary",
23-
"next-compose": "^0.0.2",
24-
"next-offline": "^5.0.0",
2522
"now": "^17.0.4",
2623
"npm-run-all": "^4.1.5",
2724
"prettier": "^1.19.1",
@@ -39,12 +36,14 @@
3936
},
4037
"dependencies": {
4138
"clsx": "^1.1.0",
39+
"next": "canary",
40+
"next-offline": "^5.0.0",
4241
"react": "^16.12.0",
4342
"react-dom": "^16.12.0"
4443
},
4544
"scripts": {
4645
"dev": "next",
47-
"now-build": "./node_modules/.bin/next build",
46+
"build": "next build",
4847
"start": "next start",
4948
"lint:ts": "eslint --cache",
5049
"lint:js": "eslint ./*.js --cache --ignore-pattern .eslintrc.js",

server.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5867,11 +5867,6 @@ neo-async@^2.5.0, neo-async@^2.6.0, neo-async@^2.6.1:
58675867
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
58685868
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==
58695869

5870-
next-compose@^0.0.2:
5871-
version "0.0.2"
5872-
resolved "https://registry.yarnpkg.com/next-compose/-/next-compose-0.0.2.tgz#fa26aa6430bc4e34d72fe9e5bca780aef53cf191"
5873-
integrity sha1-+iaqZDC8TjTXL+nlvKeArvU88ZE=
5874-
58755870
next-offline@^5.0.0:
58765871
version "5.0.0"
58775872
resolved "https://registry.yarnpkg.com/next-offline/-/next-offline-5.0.0.tgz#bd47a795965aceace38cdb60709c8ef980c49559"

0 commit comments

Comments
 (0)