-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.mjs
91 lines (81 loc) · 3.2 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
/* eslint-disable import/no-extraneous-dependencies, import/extensions */
import { fileURLToPath } from 'node:url';
import withBundleAnalyzer from '@next/bundle-analyzer';
import createJiti from 'jiti';
const BASE_PATH = process.env.BASE_PATH || '';
const ENABLE_STATIC_EXPORT = process.env.ENABLE_STATIC_EXPORT === 'true';
const rewrites = () => {
return [
{ source: '/health', destination: '/api/health' },
{ source: '/ping', destination: '/api/health' },
{ source: '/api/ping', destination: '/api/health' },
];
};
const redirects = () => {
return [];
};
const jiti = createJiti(fileURLToPath(import.meta.url));
jiti('./src/env');
const bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
/** @type {import('next').NextConfig} */
const nextConfig = {
poweredByHeader: false,
// Just to ensure that React is always on strict mode
reactStrictMode: true,
// We want to always enforce that SWC minifies the sources even during Development mode
// so that bundles are minified on-the-go. SWF minifying is fast, and has almost no penalties
swcMinify: true,
// We allow the BASE_PATH to be overridden in case that the Website
// is being built on a subdirectory (e.g. /nodejs-website)
basePath: BASE_PATH,
images: {
// We disable image optimisation during static export builds
unoptimized: ENABLE_STATIC_EXPORT,
// We allow SVGs to be used as images
dangerouslyAllowSVG: true,
// We add it to the remote pattern for the static images we use from GitHub
remotePatterns: [
{
protocol: 'https',
hostname: 'tailwindui.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'fonts.googleapis.com',
port: '',
pathname: '/**',
},
],
},
// On static export builds we want to enable the export feature
output: ENABLE_STATIC_EXPORT ? 'export' : undefined,
// This configures all the Next.js rewrites, which are used for rewriting internal URLs into other internal Endpoints
// This feature is not supported within static export builds, hence we pass an empty array if static exports are enabled
rewrites: !ENABLE_STATIC_EXPORT ? rewrites : undefined,
// This configures all Next.js redirects
redirects: !ENABLE_STATIC_EXPORT ? redirects : undefined,
// We don't want to run Type Checking on Production Builds
// as we already check it on the CI within each Pull Request
typescript: { ignoreBuildErrors: true },
// We don't want to run ESLint Checking on Production Builds
// as we already check it on the CI within each Pull Request
// we also configure ESLint to run its lint checking on all files (next lint)
eslint: { dirs: ['.'], ignoreDuringBuilds: true },
experimental: {
// A list of packages that Next.js should automatically evaluate and optimise the imports for.
// @see https://vercel.com/blog/how-we-optimized-package-imports-in-next-js
optimizePackageImports: [
'@radix-ui/react-avatar',
'@radix-ui/react-select',
'@radix-ui/react-toast',
'tailwindcss',
],
// Removes the warning regarding the WebPack Build Worker
webpackBuildWorker: false,
},
};
export default bundleAnalyzer(nextConfig);