-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
101 lines (96 loc) · 2.71 KB
/
next.config.ts
File metadata and controls
101 lines (96 loc) · 2.71 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
import path from 'node:path'
import bundleAnalyzer from '@next/bundle-analyzer'
import { withSentryConfig } from '@sentry/nextjs'
import type { NextConfig } from 'next'
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
const isLocal = process.env.NODE_ENV === 'development'
const minioUrl = process.env.NEXT_PUBLIC_MINIO_URL
const minioBucket = process.env.NEXT_PUBLIC_MINIO_BUCKET
const nextConfig: NextConfig = {
cacheComponents: true,
reactStrictMode: true,
productionBrowserSourceMaps: true,
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
images: {
...(isLocal
? {}
: {
loader: 'custom',
loaderFile: './utils/image-loader.ts',
}),
deviceSizes: [640, 1080, 1920],
imageSizes: [640, 1080, 1920],
formats: ['image/avif'],
qualities: [95],
minimumCacheTTL: 2678400,
// Allow images from MinIO for Next.js optimization in development
remotePatterns: [
{
protocol: 'http',
hostname: process.env.MINIO_ENDPOINT ?? '',
port: process.env.MINIO_PORT,
pathname: '/**',
},
],
},
headers: async () => [
{
source: '/(.*)',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
],
},
],
rewrites: async () => {
if (!minioBucket || !minioUrl) return []
return [
{
source: '/:prefix(categories|gallery|history|shared|temp)/:path*',
destination: `${minioUrl}/${minioBucket}/:prefix/:path*`,
},
]
},
webpack: config => {
config.resolve.alias['@'] = path.resolve('./')
return config
},
turbopack: {
resolveAlias: {
'@': path.resolve('./'),
},
},
redirects: async () => {
const categories = ['miscellaneous', 'recorders', 'pocket', 'mercury', 'bourdon', 'aneroid']
return categories.map(name => {
const source = `/collection/categories/${name}`
return {
source, // old route
destination: `${source}/date/1`, // new route
permanent: true,
}
})
},
allowedDevOrigins: process.env.NEXT_PUBLIC_BASE_URL
? [new URL(process.env.NEXT_PUBLIC_BASE_URL).hostname]
: [],
}
export default withSentryConfig(withBundleAnalyzer(nextConfig), {
org: 'alex-shenshin',
project: 'barometers',
silent: !process.env.CI,
widenClientFileUpload: true,
tunnelRoute: '/monitoring',
webpack: {
automaticVercelMonitors: true,
treeshake: {
removeDebugLogging: true,
},
},
})