hensei-web/next.config.js
Justin Edmund c33de6f2a6 Fix Party component interface and remove incompatible head components
- Update NewPartyClient and PartyPageClient to pass correct props to Party component
- Remove SavedHead and ProfileHead usage from client components (incompatible with App Router)
- Create debugging wrapper for Party component
- Update webpack SVG configuration with safety checks
- Add TypeScript declarations for SVG imports
- Document all fixes in PRDs

These changes address the "Element type is invalid" error by fixing component interfaces
and removing Pages Router patterns incompatible with App Router.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 02:20:21 -07:00

118 lines
2.8 KiB
JavaScript

/** @type {import('next').NextConfig} */
const path = require('path')
const { i18n } = require('./next-i18next.config')
module.exports = {
reactStrictMode: true,
sassOptions: {
prependData: '@import "variables";',
includePaths: [path.join(__dirname, 'styles')],
},
i18n,
async rewrites() {
return [
{
source: '/',
destination: '/new',
},
{
source: '/characters',
destination: '/new',
},
{
source: '/summons',
destination: '/new',
},
{
source: '/weapons',
destination: '/new',
},
{
source: '/updates',
destination: '/about',
},
{
source: '/roadmap',
destination: '/about',
},
{
source: '/p/:shortcode/preview',
destination: '/api/preview/:shortcode',
},
{
source: '/p/:shortcode/characters',
destination: '/p/:shortcode',
},
{
source: '/p/:shortcode/weapons',
destination: '/p/:shortcode',
},
{
source: '/p/:shortcode/summons',
destination: '/p/:shortcode',
},
{
source: '/p/:shortcode/:garbage',
destination: '/p/:shortcode',
},
]
},
async redirects() {
return [
{
source: '/transfer/version',
destination:
'https://raw.githubusercontent.com/Vazkii/hensei-transfer/main/version',
permanent: true,
},
]
},
webpack(config) {
// Set up alias for styles
config.resolve.alias = {
...config.resolve.alias,
'@styles': path.resolve(__dirname, 'styles'),
}
// Set up rules for SVG files
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg'),
)
if (fileLoaderRule) {
config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},
// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: /url/ }, // exclude if *.svg?url
use: ['@svgr/webpack'],
},
)
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i
} else {
// If no file loader rule exists, just add our SVG handler
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
})
}
// Disable CSS modules
// config.module.rules[2].oneOf.forEach((one) => {
// if (!`${one.issuer?.and}`.includes('_app')) return
// one.issuer.and = [path.resolve(__dirname)]
// })
return config
},
}