-
Notifications
You must be signed in to change notification settings - Fork 2
/
next.config.mjs
34 lines (28 loc) · 1.04 KB
/
next.config.mjs
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
/** @type {import('next').NextConfig} */
await import("./src/env.mjs")
import * as fs from "fs"
const redirectFile = "./_redirects"
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
output: "standalone",
// builtin redirects
redirects: async () => {
const redirects = await fs.promises.readFile(redirectFile, "utf-8")
const lines = redirects.split("\n")
return lines
.map((line) => {
if (!line.startsWith("/")) return
const data = line.trim().split(/\s+/) // handle unknown length of whitespace
if (data.length !== 2) {
console.log("Failed to parse redirect: " + line)
console.log(`Received: [${data.join(", ")}]`)
console.log("Expected: [/source, destination]")
return
}
return { source: data[0], destination: data[1], permanent: false }
})
.filter((e) => e !== undefined)
},
}
export default nextConfig