-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
39 lines (35 loc) · 1021 Bytes
/
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
const { readFileSync } = require("fs");
const withPlugins = require("next-compose-plugins");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const SLASH_REDIRECT = /^(\/\S+)\s+(\S+)(?:\s+(\d+)!?)?$/;
const netlifyRedirects = [];
readFileSync("_redirects", "utf-8")
.split(/\r?\n/)
.forEach((line) => {
const match = line.match(SLASH_REDIRECT);
if (match) {
netlifyRedirects.push({
source: match[1],
destination: match[2],
statusCode: +(match[3] || "301"),
});
}
});
const STRIPE_KEY_POSTFIX =
process.env.STRIPE_KEY_POSTFIX ||
(process.env.NODE_ENV === "production" && process.env.CONTEXT === "production"
? "_LIVE"
: "_TEST");
const nextConfig = {
target: "serverless",
redirects() {
return netlifyRedirects;
},
env: {
STRIPE_KEY_POSTFIX,
STRIPE_PK: process.env[`STRIPE_PK${STRIPE_KEY_POSTFIX}`],
},
};
module.exports = withPlugins([withBundleAnalyzer], nextConfig);