-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
50 lines (45 loc) · 1.52 KB
/
next.config.js
File metadata and controls
50 lines (45 loc) · 1.52 KB
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
const path = require("path");
const withPWA = require("next-pwa")({
dest: "public",
register: true,
skipWaiting: true,
disable: process.env.NODE_ENV === "development",
buildExcludes: ["app-build-manifest.json"],
fallbacks: {
document: "/offline",
image: "/fallback.png",
// font: '/static/font/fallback.woff2',
// audio: ...,
// video: ...,
},
});
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) => {
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;
});
};
/** @type {import("next").NextConfig} */
const nextConfig = withPWA({
reactStrictMode: true,
...(process.env.NODE_ENV !== "development" && {
webpack: (config) => {
const entry = generateAppDirEntry(config.entry);
config.entry = () => entry;
return config;
},
}),
images: {
domains: ["googleusercontent.com", "oaidalleapiprodscus.blob.core.windows.net", "cdn.openai.com"],
},
});
module.exports = nextConfig;