(config, options)
| 17 | (nextConfig = {}) => |
| 18 | Object.assign({}, nextConfig, { |
| 19 | webpack(config, options) { |
| 20 | const { |
| 21 | webpack, |
| 22 | buildId, |
| 23 | dev, |
| 24 | config: { distDir = '.next', pageExtensions = ['tsx', 'ts', 'jsx', 'js', 'mdx'], experimental = {} } |
| 25 | } = options |
| 26 | |
| 27 | let basePath = options.config.basePath |
| 28 | if (!basePath) basePath = '/' |
| 29 | |
| 30 | // For workbox configurations: |
| 31 | // https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-webpack-plugin.GenerateSW |
| 32 | const { |
| 33 | disable = false, |
| 34 | register = true, |
| 35 | dest = distDir, |
| 36 | sw = 'sw.js', |
| 37 | cacheStartUrl = true, |
| 38 | dynamicStartUrl = true, |
| 39 | dynamicStartUrlRedirect, |
| 40 | skipWaiting = true, |
| 41 | clientsClaim = true, |
| 42 | cleanupOutdatedCaches = true, |
| 43 | additionalManifestEntries, |
| 44 | ignoreURLParametersMatching = [], |
| 45 | importScripts = [], |
| 46 | publicExcludes = ['!noprecache/**/*'], |
| 47 | buildExcludes = [], |
| 48 | modifyURLPrefix = {}, |
| 49 | manifestTransforms = [], |
| 50 | fallbacks = {}, |
| 51 | cacheOnFrontEndNav = false, |
| 52 | reloadOnOnline = true, |
| 53 | scope = basePath, |
| 54 | customWorkerDir = 'worker', |
| 55 | subdomainPrefix, // deprecated, use basePath in next.config.js instead |
| 56 | ...workbox |
| 57 | } = pluginOptions |
| 58 | |
| 59 | if (typeof nextConfig.webpack === 'function') { |
| 60 | config = nextConfig.webpack(config, options) |
| 61 | } |
| 62 | |
| 63 | if (disable) { |
| 64 | options.isServer && console.log('> [PWA] PWA support is disabled') |
| 65 | return config |
| 66 | } |
| 67 | |
| 68 | if (subdomainPrefix) { |
| 69 | console.error( |
| 70 | '> [PWA] subdomainPrefix is deprecated, use basePath in next.config.js instead: https://nextjs.org/docs/api-reference/next.config.js/basepath' |
| 71 | ) |
| 72 | } |
| 73 | |
| 74 | console.log(`> [PWA] Compile ${options.isServer ? 'server' : 'client (static)'}`) |
| 75 | |
| 76 | let { runtimeCaching = defaultCache } = pluginOptions |
no test coverage detected
searching dependent graphs…