Neah/next.config.js
2025-05-03 12:05:44 +02:00

86 lines
2.1 KiB
JavaScript

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer }) => {
// Handle node: protocol imports
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
buffer: require.resolve('buffer/'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util/'),
};
// Add module concatenation for better tree shaking
config.optimization.concatenateModules = true;
// Enable deterministic ids for better caching
config.optimization.moduleIds = 'deterministic';
}
return config;
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
images: {
domains: ['espace.slm-lab.net', 'connect.slm-lab.net'],
formats: ['image/avif', 'image/webp'],
},
experimental: {
webpackBuildWorker: true,
parallelServerBuildTraces: true,
parallelServerCompiles: true,
optimizeCss: true,
serverMinification: true,
},
// Enable aggressive compression
compress: true,
// Enable production source maps for better performance debugging
productionBrowserSourceMaps: false,
// Reduce build output size
poweredByHeader: false,
// Add cache headers to immutable assets
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Content-Security-Policy',
value: "frame-ancestors 'self' https://espace.slm-lab.net https://connect.slm-lab.net"
}
]
},
{
source: '/_next/static/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
},
{
source: '/images/:path*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
}
]
},
// Add page redirects if needed
async redirects() {
return []
}
};
module.exports = withBundleAnalyzer(nextConfig);