-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.js
83 lines (74 loc) · 2.27 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
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})
const { withSentryConfig } = require("@sentry/nextjs")
const withPlugins = require("next-compose-plugins")
const { createSecureHeaders } = require("next-secure-headers")
const withTM = require("next-transpile-modules")(["ky"])
if (
!process.env.NEXT_PUBLIC_DEPLOY_ENV ||
!["dev", "staging", "production"].includes(process.env.NEXT_PUBLIC_DEPLOY_ENV)
) {
console.error("ERROR: Invalid NEXT_PUBLIC_DEPLOY_ENV")
process.exit(1)
}
if (
!process.env.NEXT_PUBLIC_FIREBASE_API_KEY ||
!process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN ||
!process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID ||
!process.env.NEXT_PUBLIC_FIREBASE_APP_ID
) {
console.error("ERROR: Firebase config needed.")
process.exit(1)
}
if (
process.env.NEXT_PUBLIC_DEPLOY_ENV !== "dev" &&
(!process.env.NEXT_PUBLIC_SENTRY_DSN ||
!process.env.SENTRY_URL ||
!process.env.SENTRY_ORG ||
!process.env.SENTRY_PROJECT ||
!process.env.SENTRY_AUTH_TOKEN)
) {
console.error("ERROR: Sentry config needed in deploy env other than dev.")
process.exit(1)
}
if (
process.env.NEXT_PUBLIC_DEPLOY_ENV !== "dev" &&
(!process.env.CONTENTFUL_SPACE_ID || !process.env.CONTENTFUL_TOKEN)
) {
console.error("ERROR: Contentful config needed in deploy env other than dev.")
process.exit(1)
}
if (!process.env.NEXT_PUBLIC_FRONTEND_URL) {
console.error("ERROR: NEXT_PUBLIC_FRONTEND_URL env variable needed.")
process.exit(1)
}
if (!process.env.NEXT_PUBLIC_BACKEND_BASE_URL) {
console.error("ERROR: NEXT_PUBLIC_BACKEND_BASE_URL env variable needed.")
process.exit(1)
}
if (!/^https?:\/\/.+\/$/.test(process.env.NEXT_PUBLIC_FRONTEND_URL)) {
console.error(
"ERROR: NEXT_PUBLIC_FRONTEND_URL env variable has a wrong format."
)
process.exit(1)
}
/** @type {import('next/dist/next-server/server/config-shared').NextConfig} */
const config = {
reactStrictMode: true,
trailingSlash: true,
eslint: {
ignoreDuringBuilds: true,
},
async headers() {
return [{ source: "/(.*)", headers: createSecureHeaders() }]
},
}
module.exports = withPlugins(
[
[withBundleAnalyzer],
process.env.NEXT_PUBLIC_SENTRY_DSN ? [withSentryConfig] : null,
[withTM],
].filter((plugin) => plugin != null),
config
)