-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Expand file tree
/
Copy pathnext.config.ts
More file actions
55 lines (50 loc) · 1.94 KB
/
Copy pathnext.config.ts
File metadata and controls
55 lines (50 loc) · 1.94 KB
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
import path from 'path';
import { initOpenNextCloudflareForDev } from '@opennextjs/cloudflare';
import withLinaria, { type LinariaConfig } from 'next-with-linaria';
import { localeToUrlSegment } from './src/platform/i18n/locale-to-url-segment';
import { buildLocaleRewrites } from './src/platform/routing/locale-rewrite-patterns';
import { WEBSITE_LOCALE_LIST } from './src/platform/i18n/website-locale-list';
// Bundler decision: Next 16 defaults dev and build to Turbopack, and
// next-with-linaria@1.3 branches on process.env.TURBOPACK to apply its
// Turbopack loader config — the same combination the original twenty-website
// already runs in dev. Webpack stays available behind `next dev --webpack`
// as the escape hatch if a wyw-in-js edge case surfaces.
const DEPLOYED_LOCALE_URL_SEGMENTS =
WEBSITE_LOCALE_LIST.map(localeToUrlSegment);
const nextConfig: LinariaConfig = {
reactCompiler: true,
linaria: {
configFile: path.resolve(__dirname, 'wyw-in-js.config.cjs'),
},
experimental: {
swcPlugins: [
[
'@lingui/swc-plugin',
{
runtimeModules: {
i18n: ['@lingui/core', 'i18n'],
trans: ['@lingui/react', 'Trans'],
},
},
],
],
},
// Clean public URLs: the source locale is unprefixed, other locales get a
// short segment. Rewrites map unprefixed paths onto the internal /[locale]
// tree; redirects canonicalize away explicit source-locale prefixes.
async rewrites() {
return {
beforeFiles: buildLocaleRewrites(DEPLOYED_LOCALE_URL_SEGMENTS),
};
},
async redirects() {
return [
{ source: '/en', destination: '/', statusCode: 301 },
{ source: '/en/:path*', destination: '/:path*', statusCode: 301 },
];
},
};
export default withLinaria(nextConfig);
// Binds the Cloudflare dev context (R2 incremental cache, env vars) into
// `next dev` so local runs mirror the deployed OpenNext worker.
initOpenNextCloudflareForDev();