Files
metabuilder/next.config.ts
copilot-swe-agent[bot] 7a3acb38a9 Phase 1: Next.js 15 migration setup and core structure
Converted project from Vite SPA to Next.js 15 with App Router:

**Dependencies:**
- Installed Next.js 15.1.6 with React 19
- Added @next/third-parties and sharp for optimization
- Updated package.json scripts for Next.js dev/build

**App Structure:**
- Created app/ directory with App Router
- Setup root layout with font optimization (IBM Plex Sans, Space Grotesk, JetBrains Mono)
- Created providers for ThemeProvider and QueryClient
- Implemented file-based routing structure

**Configuration:**
- next.config.ts with standalone output for Docker
- Image optimization config
- Webpack config for DBAL and Lua (Fengari) support
- Path aliases (@/, @/dbal)
- CORS headers for API routes

**Authentication:**
- Created AuthProvider context for client-side auth
- Middleware for route protection
- Session cookie validation
- Role-based redirects

**Routing Structure:**
```
app/
├── layout.tsx              # Root layout
├── providers.tsx           # Client providers
├── page.tsx                # Home (Level 1)
├── level1-client.tsx       # Client wrapper
├── login/                  # Login page
├── (auth)/                 # Protected routes
│   ├── dashboard/          # Level 2
│   ├── admin/              # Level 3
│   ├── builder/            # Level 4
│   └── supergod/           # Level 5
├── api/                    # API routes
└── _components/            # Shared components
```

**Features:**
- Server-side rendering ready
- Automatic code splitting
- Font optimization with next/font
- Image optimization configured
- Auth middleware protection
- Session management
- Role-based access control

**Migration Guide:**
- Created NEXTJS_MIGRATION.md with complete roadmap
- Phase 1 complete 
- Phase 2-5 in progress

**Compatibility:**
- All existing components preserved
- DBAL integration maintained
- Prisma unchanged
- Docker deployment ready (pending Dockerfile update)
- Tailwind CSS working
- Shadcn/ui components compatible

Next: Implement API routes, convert level components, update Docker.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-25 01:22:00 +00:00

129 lines
3.2 KiB
TypeScript

import type { NextConfig } from 'next'
import { resolve } from 'path'
const nextConfig: NextConfig = {
reactStrictMode: true,
// Enable SWC minification
swcMinify: true,
// Standalone output for Docker
output: 'standalone',
// Configure page extensions
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
// Experimental features
experimental: {
// Enable React Server Components
serverActions: {
bodySizeLimit: '2mb',
allowedOrigins: ['localhost:3000'],
},
// Optimize package imports
optimizePackageImports: [
'@radix-ui/react-accordion',
'@radix-ui/react-alert-dialog',
'@radix-ui/react-avatar',
'@radix-ui/react-checkbox',
'@radix-ui/react-dialog',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-label',
'@radix-ui/react-popover',
'@radix-ui/react-select',
'@radix-ui/react-tabs',
'@radix-ui/react-tooltip',
'lucide-react',
'recharts',
'd3',
],
},
// Image optimization configuration
images: {
formats: ['image/avif', 'image/webp'],
dangerouslyAllowSVG: true,
contentDispositionType: 'attachment',
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
},
{
protocol: 'https',
hostname: '**.githubusercontent.com',
},
],
},
// Webpack configuration
webpack: (config, { isServer }) => {
// Add aliases
config.resolve.alias = {
...config.resolve.alias,
'@': resolve(__dirname, 'src'),
'@/dbal': resolve(__dirname, 'dbal'),
}
// Add WASM support for Fengari (Lua)
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
}
// Handle .node files (for native modules)
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
crypto: false,
}
}
return config
},
// Redirects for old routes (if needed)
async redirects() {
return []
},
// Headers for security and CORS
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET,DELETE,PATCH,POST,PUT' },
{ key: 'Access-Control-Allow-Headers', value: 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version' },
],
},
]
},
// TypeScript configuration
typescript: {
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
ignoreBuildErrors: false,
},
// ESLint configuration
eslint: {
// Only run ESLint on these directories during production builds
dirs: ['app', 'src', 'lib', 'components'],
},
// Environment variables exposed to browser
env: {
NEXT_PUBLIC_DBAL_API_URL: process.env.DBAL_API_URL || 'http://localhost:8080',
},
}
export default nextConfig