-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
85 lines (78 loc) · 2.23 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/** @type {import('next').NextConfig} */
const path = require("path");
const withPWAInit = require("next-pwa");
const runtimeCaching = require("next-pwa/cache");
const cacheTime = 365 * 24 * 60 * 60; // 365 days
runtimeCaching.map((item) => {
item.options.expiration.maxAgeSeconds = cacheTime;
if (item.options.cacheName === "others") {
item.options.expiration.maxEntries = 200;
}
if (item.options.cacheName === "static-image-assets") {
item.options.expiration.maxEntries = 100;
}
});
const generateAppDirEntry = (entry) => {
const packagePath = require.resolve("next-pwa");
const packageDirectory = path.dirname(packagePath);
const registerJs = path.join(packageDirectory, "register.js");
return entry().then((entries) => {
// Register SW on App directory, solution: https://github.com/shadowwalker/next-pwa/pull/427
if (entries["main-app"] && !entries["main-app"].includes(registerJs)) {
if (Array.isArray(entries["main-app"])) {
entries["main-app"].unshift(registerJs);
} else if (typeof entries["main-app"] === "string") {
entries["main-app"] = [registerJs, entries["main-app"]];
}
}
return entries;
});
};
const withPWA = withPWAInit({
dest: "public",
runtimeCaching,
// Solution: https://github.com/shadowwalker/next-pwa/issues/424#issuecomment-1399683017
buildExcludes: ["app-build-manifest.json"],
mode: "production",
});
module.exports = withPWA({
// pwa: {
// dest: "public",
// runtimeCaching,
// mode: "production",
// },
webpack: (config, { dev }) => {
if (!dev) {
const entry = generateAppDirEntry(config.entry);
config.entry = () => entry;
}
return config;
},
env: {
MARVEL_PUBLIC_KEY: process.env.MARVEL_PUBLIC_KEY,
MARVEL_PRIVATE_KEY: process.env.MARVEL_PRIVATE_KEY,
APP_URL: process.env.APP_URL,
},
images: {
deviceSizes: [320, 640, 768, 1024, 1600],
remotePatterns: [
{
protocol: "https",
hostname: "**.annihil.us",
port: "",
pathname: "/**",
},
],
},
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
reactStrictMode: true,
// swcMinify: true,
compiler: {
styledComponents: true,
},
});