-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.js
45 lines (40 loc) · 1.53 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 withPWA = require('next-pwa')
const { PHASE_PRODUCTION_BUILD } = require('next/constants')
module.exports = (phase, { defaultConfig }) => {
const config = {
...defaultConfig,
eslint: {
ignoreDuringBuilds: process.env.LINTMODE === 'nolint', // for fastbuild script
},
pwa: {
dest: 'public',
dynamicStartUrl: false, // precache home page instead of storing it in runtime cache by default
register: false,
skipWaiting: false,
buildExcludes: [/middleware-manifest\.json$/], // for Next 12, see https://github.com/shadowwalker/next-pwa/issues/288
},
}
if (phase === PHASE_PRODUCTION_BUILD){
// Attributes generateBuildId and additionalManifestEntries are only needed
// for the build and calculating their value is time-consuming.
// So we add them here, just for the build.
const getBuildId = require('./util/buildid.js')
const getStaticPrecacheEntries = require('./util/staticprecache.js')
const getGeneratedPrecacheEntries = require('./util/precache.js')
const buildId = getBuildId()
config.generateBuildId = getBuildId
config.pwa.additionalManifestEntries = [
...getStaticPrecacheEntries({
// exclude icon-related files from the precache since they are platform specific
// note: no need to pass publicExcludes to next-pwa, it's not used for anything else
publicExcludes: [
'!*.png',
'!*.ico',
'!browserconfig.xml',
],
}),
...getGeneratedPrecacheEntries(buildId),
]
}
return withPWA(config)
}