forked from commercelayer/mfe-checkout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
89 lines (78 loc) · 2.24 KB
/
next.config.js
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
// @ts-check
const nextBuildId = require("next-build-id")
const shouldAnalyzeBundles = process.env.ANALYZE === "true"
/** @type { import('next').NextConfig } */
let nextConfig = {
reactStrictMode: true,
eslint: {},
output: process.env.NODE_ENV === "production" ? "export" : "standalone",
distDir: "out/dist",
poweredByHeader: false,
swcMinify: false,
webpack: (config, { webpack }) => {
const AdyenWebExcludedLocales = new Set([
"cs-CZ",
"el-GR",
"es-ES",
"hr-HR",
"ja-JP",
"ko-KR",
"ru-RU",
"zh-TW",
"zh-CN",
"hu-HU",
"ro-RO",
"sk-SK",
"pt-PT",
"pt-BR",
"sl-SI",
"fi-FI",
"ar",
"nl-NL",
"sv-SE",
"da-DK",
"no-NO",
])
const adyenIgnorePluginConfig = new webpack.IgnorePlugin({
checkResource(resource, context) {
if (!/@adyen\/adyen-web\/dist\/es/.test(context)) return false
// Extract the filename from the resource path
const parts = resource.split("/")
const filenameWithExtension = parts[parts.length - 1]
// Remove the file extension
const filename = filenameWithExtension.replace(/\.[^/.]+$/, "")
return AdyenWebExcludedLocales.has(filename)
},
})
config.plugins.push(adyenIgnorePluginConfig)
return config
},
// When when app is exported as SPA and served in a sub-folder
assetPrefix: process.env.NEXT_PUBLIC_BASE_PATH
? `${process.env.NEXT_PUBLIC_BASE_PATH}/`
: undefined,
// https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
pageExtensions: ["page.tsx"],
generateBuildId: () => nextBuildId({ dir: __dirname }),
}
// rewrite rules affect only development mode, since Next router will return 404 for paths that only exist in react-router
if (process.env.NODE_ENV !== "production") {
nextConfig = {
...nextConfig,
async rewrites() {
return [
{
source: "/:any*",
destination: "/",
},
]
},
}
}
if (shouldAnalyzeBundles) {
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: true,
})
nextConfig = withBundleAnalyzer(nextConfig)
}
module.exports = nextConfig