-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.mjs
92 lines (78 loc) · 1.97 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
import bundleAnalyzer from '@next/bundle-analyzer';
import createNextIntlPlugin from 'next-intl/plugin';
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
const isProd = process.env.NODE_ENV === 'production';
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
trailingSlash: true,
swcMinify: true,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '*.res.cloudinary.com',
},
{
protocol: 'https',
hostname: '*.rackcdn.com',
},
{
protocol: 'https',
hostname: '*.s3-eu-west-1.amazonaws.com',
},
{
protocol: 'https',
hostname: '*.commercetools.com',
},
{
protocol: 'https',
hostname: '*.googleapis.com',
},
],
formats: ['image/avif', 'image/webp'],
},
productionBrowserSourceMaps: true,
env: {
NEXT_PUBLIC_EXT_BUILD_ID:
process.env.NEXT_PUBLIC_EXT_BUILD_ID ??
JSON.stringify(process.env.NETLIFY ? process.env.COMMIT_REF.substring(0, 7) : 'staging'),
},
compiler: {
reactRemoveProperties: isProd ? { properties: ['^data-test'] } : false,
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
exclude: /flag-icons/,
use: ['@svgr/webpack'],
});
return config;
},
async redirects() {
return [
{
source: '/storybook',
destination: '/storybook/index.html',
permanent: true,
},
];
},
async rewrites() {
return [
{ source: '/__preview/:path*', destination: '/preview/:path*' },
{ source: '/:locale/__preview/:path*', destination: '/:locale/preview/:path*' },
];
},
experimental: {
appDir: true,
},
};
const withNextIntl = createNextIntlPlugin();
const plugins = [withBundleAnalyzer, withNextIntl];
const nextConfig = () => {
return plugins.reduce((acc, plugin) => plugin(acc), config);
};
export default nextConfig;