sysrot-hub
Version:
CLI de nueva generación para proyectos Next.js 14+ con IA multi-modelo, Web3 integration, internacionalización completa y roadmap realista 2025-2026
136 lines (125 loc) • 3.23 kB
JavaScript
/** @type {import('next').NextConfig} */
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer');
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
// Enhanced i18n configuration
i18n: {
locales: ['es', 'en'],
defaultLocale: 'es',
localeDetection: false,
},
// Advanced image optimization
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'images.unsplash.com',
port: '',
pathname: '/**',
},
],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
formats: ['image/webp', 'image/avif'],
minimumCacheTTL: 86400, // 24 hours
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
// Performance optimizations
experimental: {
optimizePackageImports: ['lucide-react', 'framer-motion'],
optimizeCss: true,
webVitalsAttribution: ['CLS', 'LCP'],
},
// Compression and optimization
compress: true,
poweredByHeader: false,
// PWA and Service Worker preparation
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
// Webpack configuration
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Bundle analyzer
if (process.env.ANALYZE === 'true') {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true,
})
);
}
// Performance optimizations
if (!dev && !isServer) {
config.optimization = {
...config.optimization,
splitChunks: {
chunks: 'all',
minSize: 20000,
maxSize: 244000,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
common: {
name: 'common',
minChunks: 2,
chunks: 'all',
enforce: true,
},
},
},
};
}
// Critical CSS and resource hints will be handled by custom _document
return config;
},
// Headers for performance and security
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
},
],
},
{
source: '/sw.js',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=0, must-revalidate',
},
],
},
];
},
}
module.exports = nextConfig