-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathnext.config.mjs
More file actions
172 lines (161 loc) · 4.26 KB
/
next.config.mjs
File metadata and controls
172 lines (161 loc) · 4.26 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { withSentryConfig } from "@sentry/nextjs";
const MappingReplacement = await import("./redirects.json", {
with: { type: "json" },
});
const sentryConfig = {
// Sentry webpack plugin options
org: process.env.NEXT_PUBLIC_SENTRY_ORG,
project: process.env.NEXT_PUBLIC_SENTRY_PROJECT,
url: process.env.NEXT_PUBLIC_SENTRY_URL,
authToken: process.env.SENTRY_AUTH_TOKEN,
// Source maps configuration
sourcemaps: {
assets: ".next/**/*.{js,map}",
ignore: ["node_modules/**/*"],
rewrite: true,
stripPrefix: ["webpack://_N_E/", "webpack://", "app://"],
urlPrefix: "app:///_next",
},
// Debug and release configuration
silent: false,
debug: true,
release:
process.env.NEXT_PUBLIC_SENTRY_RELEASE ||
process.env.NEXT_PUBLIC_GITHUB_SHA ||
"dev",
dist: process.env.NEXT_PUBLIC_GITHUB_SHA || "dev",
setCommits: {
auto: true,
ignoreMissing: true,
},
deploy: {
env: process.env.NEXT_PUBLIC_SENTRY_ENV || "development",
dist: process.env.NEXT_PUBLIC_GITHUB_SHA || "dev",
},
injectBuildInformation: true,
};
const sentrySdkConfig = {
tunnelRoute: false,
widenClientFileUpload: true,
hideSourceMaps: false,
disableLogger: true,
// Enable component names and release injection
includeNames: true,
release: {
inject: true,
name:
process.env.NEXT_PUBLIC_SENTRY_RELEASE ||
process.env.NEXT_PUBLIC_GITHUB_SHA ||
"dev",
},
// Server instrumentation options
autoInstrumentServerFunctions: true,
autoInstrumentMiddleware: true,
automaticVercelMonitors: true,
};
const nextConfig = {
// Issue with meta rendering : https://github.com/vercel/next.js/issues/79313
htmlLimitedBots: /.*/,
poweredByHeader: false,
compiler: {
reactRemoveProperties:
process.env.NEXT_PUBLIC_APP_ENV === "production"
? { properties: ["data-testid"] }
: false,
},
reactCompiler: true,
staticPageGenerationTimeout: 60 * 5, // 5 minutes
webpack: (config, { dev, isServer }) => {
config.module.rules.push({
test: /\.woff2$/,
type: "asset/resource",
});
// Configure source maps for production
if (!isServer && !dev) {
config.devtool = "source-map";
config.optimization = {
...config.optimization,
minimize: true,
moduleIds: "deterministic",
chunkIds: "deterministic",
};
}
return config;
},
transpilePackages: [
"@codegouvfr/react-dsfr",
"import-in-the-middle",
"require-in-the-middle",
],
};
const moduleExports = {
...nextConfig,
async headers() {
const headers = [
{
key: "X-Content-Type-Options",
value: "nosniff",
},
];
if (process.env.NEXT_PUBLIC_IS_PRODUCTION_DEPLOYMENT) {
headers.push({
key: "X-Robots-Tag",
value: "all",
});
} else {
headers.push({
key: "X-Robots-Tag",
value: "noindex, nofollow, nosnippet",
});
}
return [
// `widget-loader.js` is meant to be embedded on third-party websites.
// When used with Subresource Integrity (SRI), browsers fetch it with CORS.
{
source: "/widget-loader.js",
headers: [
{
key: "Access-Control-Allow-Origin",
value: "*",
},
{
key: "Access-Control-Allow-Methods",
value: "GET, OPTIONS",
},
],
},
// `/widget.js` is meant to be embedded on third-party websites. When used
// with Subresource Integrity (SRI), browsers fetch it with CORS.
{
source: "/widget.js",
headers: [
{
key: "Access-Control-Allow-Origin",
value: "*",
},
{
key: "Access-Control-Allow-Methods",
value: "GET, OPTIONS",
},
],
},
{
source: "/:path*",
headers,
},
{
source: "/((?!widgets|widget.html$).*)", // all paths except those starting with "/widgets" or /widget.html used in widgets
headers: [
{
key: "X-Frame-Options",
value: "DENY",
},
],
},
];
},
async redirects() {
return MappingReplacement.default;
},
};
export default withSentryConfig(moduleExports, sentryConfig, sentrySdkConfig);