2026-10-05 15:00:46 +00:00
|
|
|
import { withFontCopy } from '@lumina/island/tools/font-copy-plugin';
|
|
|
|
|
import { withIconSprite } from '@lumina/island/tools/icon-sprite-plugin';
|
2026-10-02 14:19:11 +00:00
|
|
|
import type { NextConfig } from 'next';
|
|
|
|
|
|
2026-10-05 15:00:46 +00:00
|
|
|
// Fonts and the icon sprite keep fixed names; a changed font gets a new name, and the sprite a new
|
|
|
|
|
// ?v= (0011, 0012). Next serves public/ with max-age=0, so without this every visit asks for them again.
|
|
|
|
|
const immutable = [
|
|
|
|
|
{ key: 'Cache-Control', value: 'public, max-age=31536000, immutable' },
|
|
|
|
|
];
|
|
|
|
|
|
2026-10-02 14:19:11 +00:00
|
|
|
const nextConfig: NextConfig = {
|
|
|
|
|
// Workspace packages export TypeScript source, so Next.js compiles them.
|
|
|
|
|
transpilePackages: [
|
|
|
|
|
'@lumina/market',
|
|
|
|
|
'@lumina/integrations',
|
|
|
|
|
'@lumina/island',
|
|
|
|
|
'@lumina/libs',
|
|
|
|
|
'@lumina/tools',
|
|
|
|
|
],
|
|
|
|
|
// `/@{username}` is the public channel URL. A folder named `@…` is a
|
|
|
|
|
// parallel-route slot in the App Router, so the routes live under
|
|
|
|
|
// `channels/[username]` and the public URL is rewritten onto them.
|
|
|
|
|
async rewrites() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
source: '/@:username/:path*',
|
|
|
|
|
destination: '/channels/:username/:path*',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
},
|
2026-10-05 15:00:46 +00:00
|
|
|
async headers() {
|
|
|
|
|
return [
|
|
|
|
|
{ source: '/fonts/:path*', headers: immutable },
|
|
|
|
|
{ source: '/icons/:path*', headers: immutable },
|
|
|
|
|
];
|
|
|
|
|
},
|
2026-10-02 14:19:11 +00:00
|
|
|
// One canonical URL per channel: send direct `/channels/…` hits to `/@…`.
|
|
|
|
|
async redirects() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
source: '/channels/:username/:path*',
|
|
|
|
|
destination: '/@:username/:path*',
|
|
|
|
|
permanent: true,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2026-10-05 15:00:46 +00:00
|
|
|
// On next dev and next build, island's plugins write the fonts and icon sprite into public/
|
|
|
|
|
// under their fixed names, with no hash (0012).
|
|
|
|
|
export default withIconSprite(withFontCopy(nextConfig));
|