-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
46 lines (42 loc) · 1.33 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const withOffline = require('next-offline')
const { PHASE_PRODUCTION_SERVER } =
process.env.NODE_ENV === 'development'
? {} // We're never in "production server" phase when in development mode
: !process.env.NOW_REGION
? require('next/constants') // Get values from `next` package when building locally
: require('next-server/constants'); // Get values from `next-server` package when building on now v2
module.exports = (phase, { defaultConfig }) => {
if (phase === PHASE_PRODUCTION_SERVER) {
// Config used to run in production.
return {};
}
const withCSS = require('@zeit/next-css');
return withCSS(withOffline({
target: "serverless",
workboxOpts: {
importWorkboxFrom: 'local',
runtimeCaching: [{
urlPattern: /\.(?:png|mp3|svg)$/,
handler: 'cacheFirst',
options: {
cacheName: 'assets',
expiration: {
maxEntries: 666,
maxAgeSeconds: 30 * 24 * 60 * 60 // 30 days
}
}
},{
urlPattern: /\.js$|\.json$|/,
handler: 'staleWhileRevalidate',
options: {
cacheName: 'pages',
expiration: {
maxEntries: 666,
maxAgeSeconds: 30 * 24 * 60 * 60 // 30 days
}
}
}
]
}
}));
};