Files
TODOLIST/frontend/next.config.js
beabigegg a2f024704c backup
2025-09-12 07:37:26 +08:00

58 lines
1.5 KiB
JavaScript

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: /(?<!node_modules.*)[\\/]node_modules[\\/](react|react-dom|scheduler|prop-types|use-subscription)[\\/]/,
priority: 40,
enforce: true,
},
lib: {
test(module) {
return module.size() > 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