forked from sambecker/exif-photo-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
101 lines (89 loc) 路 2.63 KB
/
Copy pathnext.config.ts
File metadata and controls
101 lines (89 loc) 路 2.63 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 { removeUrlProtocol } from '@/utility/url';
import type { NextConfig } from 'next';
import { RemotePattern } from 'next/dist/shared/lib/image-config';
import path from 'path';
const VERCEL_BLOB_STORE_ID = process.env.BLOB_READ_WRITE_TOKEN?.match(
/^vercel_blob_rw_([a-z0-9]+)_[a-z0-9]+$/i,
)?.[1].toLowerCase();
const HOSTNAME_VERCEL_BLOB = VERCEL_BLOB_STORE_ID
? `${VERCEL_BLOB_STORE_ID}.public.blob.vercel-storage.com`
: undefined;
const HOSTNAME_CLOUDFLARE_R2 =
process.env.NEXT_PUBLIC_CLOUDFLARE_R2_PUBLIC_DOMAIN;
const HOSTNAME_AWS_S3 =
process.env.NEXT_PUBLIC_AWS_S3_BUCKET &&
process.env.NEXT_PUBLIC_AWS_S3_REGION
// eslint-disable-next-line max-len
? `${process.env.NEXT_PUBLIC_AWS_S3_BUCKET}.s3.${process.env.NEXT_PUBLIC_AWS_S3_REGION}.amazonaws.com`
: undefined;
const HOSTNAME_MINIO =
process.env.NEXT_PUBLIC_MINIO_DOMAIN;
const MINIO_PORT =
process.env.NEXT_PUBLIC_MINIO_PORT;
const MINIO_USE_SSL =
process.env.NEXT_PUBLIC_MINIO_DISABLE_SSL !== '1';
const generateRemotePattern = (
hostname: string,
port?: string,
useSSL = true,
): RemotePattern => ({
protocol: useSSL ? 'https' : 'http',
hostname: removeUrlProtocol(hostname)!,
port,
pathname: '/**',
});
const remotePatterns: RemotePattern[] = [
{
protocol: 'https',
hostname: 'api.qrserver.com',
port: '',
pathname: '/v1/create-qr-code/**',
},
];
if (HOSTNAME_VERCEL_BLOB) {
remotePatterns.push(generateRemotePattern(HOSTNAME_VERCEL_BLOB));
}
if (HOSTNAME_CLOUDFLARE_R2) {
remotePatterns.push(generateRemotePattern(HOSTNAME_CLOUDFLARE_R2));
}
if (HOSTNAME_AWS_S3) {
remotePatterns.push(generateRemotePattern(HOSTNAME_AWS_S3));
}
if (HOSTNAME_MINIO) {
remotePatterns.push(generateRemotePattern(
HOSTNAME_MINIO,
MINIO_PORT,
MINIO_USE_SSL,
));
}
const LOCALE = process.env.NEXT_PUBLIC_LOCALE || 'en-us';
const LOCALE_ALIAS = './date-fns-locale-alias';
const LOCALE_DYNAMIC = `i18n/locales/${LOCALE}`;
const IMAGE_QUALITY =
process.env.NEXT_PUBLIC_IMAGE_QUALITY
? parseInt(process.env.NEXT_PUBLIC_IMAGE_QUALITY)
: 75;
const nextConfig: NextConfig = {
images: {
imageSizes: [200],
qualities: [75, IMAGE_QUALITY],
remotePatterns,
minimumCacheTTL: 31536000,
},
serverExternalPackages: ['exifr'],
turbopack: {
resolveAlias: {
[LOCALE_ALIAS]: `@/${LOCALE_DYNAMIC}`,
},
},
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
[LOCALE_ALIAS]: path.resolve(__dirname, `src/${LOCALE_DYNAMIC}`),
};
return config;
},
};
module.exports = process.env.ANALYZE === 'true'
? require('@next/bundle-analyzer')()(nextConfig)
: nextConfig;