const crypto = require('crypto') /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, swcMinify: true, output: 'export', trailingSlash: true, images: { unoptimized: true, }, env: { NEXT_PUBLIC_API_URL: '', }, webpack: (config, { dev, isServer }) => { // 在生產環境中禁用 HMR 相關功能 if (!dev && !isServer) { config.optimization = { ...config.optimization, splitChunks: { chunks: 'all', cacheGroups: { default: false, vendors: false, framework: { chunks: 'all', name: 'framework', test: /(? 160000 && /node_modules[/\\]/.test(module.identifier()) }, name(module) { const hash = crypto.createHash('sha1') hash.update(module.identifier()) return hash.digest('hex').substring(0, 8) }, priority: 30, minChunks: 1, reuseExistingChunk: true, }, commons: { name: 'commons', minChunks: 2, priority: 20, }, }, }, } } return config }, } module.exports = nextConfig