-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.mjs
162 lines (157 loc) · 4.68 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
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
import NextBundleAnalyzer from '@next/bundle-analyzer';
import withSVGR from './utils/SVGR.mjs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/** @type {import('next').NextConfig} */
const nextConfig = {
compiler: {
styledComponents: true,
},
distDir: '.next',
cleanDistDir: true,
configOrigin: 'default',
useFileSystemPublicRoutes: true,
generateEtags: true,
pageExtensions: ['js', 'jsx', 'mjs', 'ts', 'tsx', 'md', 'mjs', 'cjs', 'mts', 'cts', 'csv'],
poweredByHeader: true,
compress: true,
optimizeFonts: true,
excludeDefaultMomentLocales: true,
reactProductionProfiling: false,
reactStrictMode: false,
outputFileTracing: true,
staticPageGenerationTimeout: 60,
swcMinify: true,
eslint: {
ignoreDuringBuilds: false,
},
typescript: {
ignoreBuildErrors: false,
tsconfigPath: 'tsconfig.json',
},
httpAgentOptions: {
keepAlive: true,
},
devIndicators: {
buildActivity: true,
buildActivityPosition: 'bottom-right',
},
onDemandEntries: {
maxInactiveAge: 60 * 1000,
pagesBufferLength: 5,
},
images: {
path: '/_next/image',
loader: 'default',
disableStaticImages: false,
minimumCacheTTL: 60,
formats: ['image/avif', 'image/webp'],
dangerouslyAllowSVG: false,
contentSecurityPolicy: `script-src 'none'; frame-src 'none'; sandbox;`,
contentDispositionType: 'inline',
remotePatterns: [
{
protocol: 'http',
hostname: '**/*',
pathname: '**/*',
},
{
protocol: 'https',
hostname: '**/*',
pathname: '**/*'
}
],
},
async headers() {
return [
{
// This applies to all routes
source: '/:path*',
headers: [
{ // controls DNS prefetching, allowing browsers to proactively perform domain name resolution
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{ // indicates whether the site should be allowed to be displayed within an iframe, protects against clickjacking attacks
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{ // prevents the browser from attempting to guess the type of content if the Content-Type header is not explicitly set. This can prevent XSS exploits for websites that allow users to upload and share files.
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{ // controls how much information the browser includes when navigating from the current website (origin) to another.
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
}
]
},
{
source: '/api/:path*',
headers: [
{
key: 'Cache-Control',
value: 'no-store, max-age=0, must-revalidate',
},
{
key: 'Pragma',
value: 'no-cache',
},
],
},
{
source: '/api/auth/:path*',
headers: [
{
key: 'Cache-Control',
value: 'private, no-cache, no-store, max-age=0, must-revalidate',
},
{
key: 'Pragma',
value: 'no-cache',
},
],
},
];
},
experimental: {
// serverComponentsExternalPackages: ["yjs"],
scrollRestoration: true,
webpackBuildWorker: true,
serverMinification: true,
clientRouterFilter: true,
middlewarePrefetch: 'flexible',
optimisticClientCache: true,
isrFlushToDisk: true,
optimizeCss: true, // ? https://github.com/vercel/next.js/issues/60473
gzipSize: true,
esmExternals: true,
outputFileTracingRoot: process.env.NEXT_PRIVATE_OUTPUT_TRACE_ROOT || '',
swcTraceProfiling: false,
forceSwcTransforms: false,
swcPlugins: undefined,
webVitalsAttribution: ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'],
mdxRs: false, // experimental rust-based mdx compiler
nextScriptWorkers: false,
},
webpack: (config, { isServer }) => {
config.module.rules.push({
test: /\.csv$/,
loader: 'raw-loader'
});
// https://github.com/yjs/yjs/issues/438#issuecomment-2225079409
if (!isServer) {
// Ensure that all imports of 'yjs' resolve to the same instance
config.resolve.alias['yjs'] = path.resolve(__dirname, 'node_modules/yjs');
config.resolve.alias['y-prosemirror'] = path.resolve(__dirname, 'node_modules/y-prosemirror');
}
return config;
},
};
const withBundleAnalyzer = NextBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
const config = withBundleAnalyzer(withSVGR(nextConfig));
export default config;