fix: pwa config position

This commit is contained in:
DIYgod 2023-01-23 19:16:16 +00:00
parent 11e9dcc5bc
commit ec0d836c59
No known key found for this signature in database
1 changed files with 34 additions and 31 deletions

View File

@ -5,10 +5,43 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})
const execSync = require("child_process").execSync
const cache = require("next-pwa/cache")
const withPWA = require("next-pwa")({
dest: "public",
publicExcludes: ["*"],
runtimeCaching: [
{
urlPattern: ({ url }) => {
return /\/ipfs\/([^/?#]+)$/.test(url.toString())
},
handler: "CacheFirst",
options: {
cacheName: "next-ipfs",
expiration: {
maxEntries: 64,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
{
urlPattern: /\/_next\/image\?url=.+%2Fipfs%2F([^/?#]+)$/i,
handler: "CacheFirst",
options: {
cacheName: "next-ipfs",
expiration: {
maxEntries: 64,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
},
},
// @ts-ignore
...cache,
],
})
const cache = require("next-pwa/cache")
const lastCommitCommand = "git rev-parse HEAD"
@ -71,35 +104,5 @@ module.exports = withBundleAnalyzer(
ENV_OPENSEA_API_KEY: process.env.OPENSEA_API_KEY,
ENV_POAP_API_KEY: process.env.POAP_API_KEY,
},
pwa: {
publicExcludes: ["*"],
dynamicStartUrl: true,
runtimeCaching: [
{
urlPattern: /\/(ipfs)\/([^/?#]+)/i,
handler: "CacheFirst",
options: {
cacheName: "next-ipfs",
expiration: {
maxEntries: 64,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
},
},
{
urlPattern: /\/_next\/image\?url=.+%2Fipfs%2F([^/?#]+)$/i,
handler: "CacheFirst",
options: {
cacheName: "next-ipfs",
expiration: {
maxEntries: 64,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
},
},
...cache,
],
},
}),
)