Skip to content

Commit 248aef9

Browse files
committed
prefix default locale by using nextjs redirects and ignore heavy deps from output
1 parent ba9d4a7 commit 248aef9

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed

netlify.toml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,4 @@
3636
[[plugins.inputs.audits]]
3737
path = "en/developers/docs/intro-to-ethereum/"
3838
[[plugins.inputs.audits]]
39-
path = "en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/"
40-
41-
[functions]
42-
43-
[functions.___netlify-odb-handler]
44-
external_node_modules = ["sharp"]
45-
included_files = [
46-
"./src/intl/**/*",
47-
"!./public/**/*",
48-
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/router-context*",
49-
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/amp-context*",
50-
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context*",
51-
"node_modules/sharp/**/*",
52-
]
53-
54-
[functions.___netlify-handler]
55-
included_files = [
56-
"./src/intl/**/*",
57-
"!./public/**/*",
58-
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/router-context*",
59-
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/amp-context*",
60-
"node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context*",
61-
]
39+
path = "en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/"

next-i18next.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ module.exports = {
1313
// url. Ref: https://nextjs.org/docs/pages/building-your-application/routing/internationalization#prefixing-the-default-locale
1414
defaultLocale: "default",
1515
// supported locales defined in `i18n.config.json`
16-
locales: ["default", ...locales],
17-
localeDetection: false,
16+
locales: [...locales, "default"],
1817
},
1918
// define custom location for intl files, otherwise default to public/locales (https://github.com/i18next/next-i18next#2-translation-content)
2019
localePath: "./src/intl",

next.config.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,55 @@ module.exports = (phase, { defaultConfig }) => {
3838
images: {
3939
deviceSizes: [640, 750, 828, 1080, 1200, 1504, 1920],
4040
},
41+
async redirects() {
42+
/**
43+
* Redirect /default to /en.
44+
*
45+
* This allows us to always have a default locale prefix for all URLs.
46+
*
47+
* @see https://github.com/vercel/next.js/discussions/18419#discussioncomment-327128
48+
*/
49+
return [
50+
{
51+
source: "/default",
52+
destination: "/en",
53+
locale: false,
54+
permanent: false,
55+
},
56+
{
57+
source: "/default/:slug*",
58+
destination: "/en/:slug*",
59+
locale: false,
60+
permanent: false,
61+
},
62+
]
63+
},
4164
}
4265

4366
if (phase !== PHASE_DEVELOPMENT_SERVER) {
44-
nextConfig = { ...nextConfig, experimental }
67+
nextConfig = {
68+
...nextConfig,
69+
experimental: {
70+
...experimental,
71+
outputFileTracingExcludes: {
72+
"*": [
73+
/**
74+
* Exclude these paths from the trace output to avoid bloating the
75+
* Netlify functions bundle.
76+
*
77+
* @see https://github.com/orgs/vercel/discussions/103#discussioncomment-5427097
78+
* @see https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files
79+
*/
80+
"node_modules/@swc/core-linux-x64-gnu",
81+
"node_modules/@swc/core-linux-x64-musl",
82+
"node_modules/@esbuild/linux-x64",
83+
"public/**/*.png",
84+
"public/**/*.gif",
85+
"src/data",
86+
],
87+
},
88+
},
89+
}
4590
}
4691

4792
return nextConfig

0 commit comments

Comments
 (0)