flnxi-Wu/next.config.js
2026-05-25 17:12:11 +08:00

60 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
productionBrowserSourceMaps: false,
compress: true,
swcMinify: true,
eslint: {
// 在生产构建时忽略ESLint错误
ignoreDuringBuilds: true,
},
typescript: {
// 在生产构建时忽略TypeScript错误(如果需要)
// ignoreBuildErrors: true,
},
// 解决 music-metadata-browser 的 Node.js polyfill 问题
webpack: (config, { isServer }) => {
if (!isServer) {
// 客户端构建时提供 Node.js 模块的 polyfill
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
path: false,
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer/'),
string_decoder: require.resolve('string_decoder/'),
}
}
return config
},
images: {
remotePatterns: (() => {
const hosts = (process.env.IMAGE_REMOTE_HOSTS || '').split(',').map(s => s.trim()).filter(Boolean)
const defaults = ['localhost']
const all = Array.from(new Set([...defaults, ...hosts]))
const patterns = []
for (const h of all) {
patterns.push({ protocol: 'https', hostname: h })
patterns.push({ protocol: 'http', hostname: h })
}
return patterns
})(),
},
experimental: {
serverActions: {
bodySizeLimit: '10gb', // Server Actions 的限制 (10GB)
},
instrumentationHook: true, // 启用 instrumentation.ts
},
// 允许构建时出现预渲染错误(这些页面会在运行时动态渲染)
onDemandEntries: {
maxInactiveAge: 25 * 1000,
pagesBufferLength: 2,
},
// 注意:CORS配置移到middleware.ts中处理,因为需要动态设置origin
// 当使用credentials时,不能使用通配符*
}
module.exports = nextConfig