-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnext.config.js
131 lines (116 loc) · 3.75 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
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
/* eslint-disable */
const CircularDependencyPlugin = require('circular-dependency-plugin');
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
const { withSentryConfig } = require('@sentry/nextjs');
const webpack = require('webpack');
const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ['i.creativecommons.org', 's3.amazonaws.com', process.env.S3_AWS_S3_BUCKET_NAME, 'i.ytimg.com'].filter(
(i) => !!i
),
minimumCacheTTL: 60,
},
compiler: {
styledComponents: true,
},
experimental: {
useDeploymentId: true, // skew protection
scrollRestoration: true,
},
i18n: {
locales: ['en', 'fr'],
defaultLocale: 'en',
},
// N.B. Production builds complain that this is not allowed (warning in Next.js version 13)
// However, it's ok for now. In the future, Sentry v8 will make this the default, it will
// be safe to remove then.
sentry: {
hideSourceMaps: true,
},
async redirects() {
return [
{
source: '/resource/:path*',
destination: `https://${process.env.S3_AWS_S3_BUCKET_NAME}/:path*`,
permanent: false,
},
{
source: '/.well-known/host-meta',
destination: '/api/social/.well-known/host-meta',
permanent: false,
},
{
source: '/.well-known/webfinger',
destination: '/api/social/.well-known/webfinger',
permanent: false,
},
];
},
webpack: (config, { dev, buildId, ...other }) => {
config.plugins.push(
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /node_modules/,
// include specific files based on a RegExp
//include: /client|server|shared/,
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd(),
})
);
config.plugins.push(
new webpack.DefinePlugin({
'process.env.BUILD_ID': JSON.stringify(buildId),
'process.env.NEXT_PUBLIC_VERCEL_GITHUB_COMMIT_SHA': process.env.VERCEL_GITHUB_COMMIT_SHA,
})
);
if (!dev) {
// TODO(mime): try to re-enable this but with SWC it was breaking, was only working with Babel.
// https://formatjs.io/docs/guides/advanced-usage#react-intl-without-parser-40-smaller
// config.resolve.alias['@formatjs/icu-messageformat-parser'] = '@formatjs/icu-messageformat-parser/no-parser';
}
return config;
},
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'no-referrer-when-downgrade',
},
],
},
];
},
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);