generated from LordRonz/nextjs-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.ts
114 lines (108 loc) · 2.93 KB
/
next.config.ts
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
/* eslint-disable unused-imports/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable import/no-extraneous-dependencies */
import bundleAnalyzer from '@next/bundle-analyzer';
import withSerwistInit from '@serwist/next';
import type { NextConfig } from 'next';
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
const nextConfig = async (
_phase: string,
{ defaultConfig: _ }: { defaultConfig: NextConfig },
) => {
let nextConfig: NextConfig = {
async rewrites() {
return [
{
source: '/quotes-api/:slug*',
destination:
'https://satisfactory-melli-lordronz-f2473ffe.koyeb.app/:slug*',
},
{
source: '/umami/script.js',
destination: 'https://cloud.umami.is/script.js',
},
];
},
poweredByHeader: false,
compiler: {
...(process.env.NODE_ENV === 'production' && {
removeConsole: {
exclude: ['error', 'info'],
},
}),
},
reactStrictMode: true,
webpack: (config, { dev, isServer }) => {
// Replace React with Preact only in client production build
// if (!dev && !isServer) {
// Object.assign(config.resolve.alias, {
// 'react/jsx-runtime.js': 'preact/compat/jsx-runtime',
// react: 'preact/compat',
// 'react-dom/test-utils': 'preact/test-utils',
// 'react-dom': 'preact/compat',
// });
// }
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: [
{
loader: '@svgr/webpack',
options: {
typescript: true,
icon: true,
},
},
],
});
return config;
},
experimental: {
turbo: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'], // https://github.com/vercel/turbo/issues/4832
as: '*.js',
},
},
},
viewTransition: true,
optimizePackageImports: [
'react-intersection-observer',
'framer-motion',
'@react-three/fiber',
'@react-three/drei',
'motion',
],
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com',
port: '',
search: '',
},
{
protocol: 'https',
hostname: 'cdn.discordapp.com',
port: '',
search: '',
},
],
},
};
if (process.env.NODE_ENV === 'production') {
const withSerwist = withSerwistInit({
// Note: This is only an example. If you use Pages Router,
// use something else that works, such as "service-worker/index.ts".
swSrc: 'src/service-worker/sw.ts',
swDest: 'public/sw.js',
});
nextConfig = withSerwist(nextConfig);
}
return withBundleAnalyzer(nextConfig);
};
export default nextConfig;