-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
76 lines (70 loc) · 2.04 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
const webpack = require("webpack");
const runtimeCaching = require("next-pwa/cache");
const path = require("path");
const withPWA = require("next-pwa")({
dest: "public",
customWorkerDir: "src/workers",
runtimeCaching,
buildExcludes: [/middleware-manifest.json$/, "/app-build-manifest.json$/"],
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
distDir: "dist",
eslint: {
ignoreDuringBuilds: true,
},
async rewrites() {
return [
{
source: "/login",
destination: "/LoginScreen",
},
{
source: "/play",
destination: "/PlayScreen",
},
{
source: "/activity",
destination: "/ActivityScreen",
},
];
},
webpack: (config, { isServer }) => {
const registerJs = path.join(
path.dirname(require.resolve("next-pwa")),
"register.js",
);
const entry = config.entry;
config.entry = () =>
entry().then((entries) => {
// Automatically registers the SW and enables certain `next-pwa` features in
// App Router (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;
});
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
stream: require.resolve("stream-browserify"),
crypto: require.resolve("crypto-browserify"),
};
config.plugins.push(
new webpack.ProvidePlugin({
process: "process/browser",
}),
new webpack.NormalModuleReplacementPlugin(/node:crypto/, (resource) => {
resource.request = resource.request.replace(/^node:/, "");
}),
);
}
return config;
},
};
module.exports = withPWA(nextConfig);