mediahub-fe/next.config.mjs

111 lines
2.6 KiB
JavaScript
Raw Normal View History

2024-11-26 03:09:48 +00:00
import createNextIntlPlugin from "next-intl/plugin";
import nextra from "nextra";
import withBundleAnalyzer from "@next/bundle-analyzer";
/** @type {import('next').NextConfig} */
const withNextIntl = createNextIntlPlugin();
const withNextra = nextra({
theme: "nextra-theme-docs",
themeConfig: "./theme.config.tsx",
});
const bundleAnalyzer = withBundleAnalyzer({
2024-12-24 12:55:28 +00:00
enabled: process.env.ANALYZE === "true",
2024-11-26 03:09:48 +00:00
});
const nextConfig = {
// Performance optimizations
experimental: {
optimizePackageImports: [
'@radix-ui/react-icons',
'lucide-react',
'react-icons',
'framer-motion',
'apexcharts',
'recharts',
'chart.js',
'react-chartjs-2'
],
},
// Image optimization
2024-11-26 03:09:48 +00:00
images: {
formats: ['image/webp', 'image/avif'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
2024-11-26 03:09:48 +00:00
remotePatterns: [
{
protocol: "https",
hostname: "api.lorem.space",
},
{
protocol: "https",
hostname: "lh3.googleusercontent.com",
},
{
protocol: "https",
hostname: "a0.muscache.com",
},
{
protocol: "https",
hostname: "avatars.githubusercontent.com",
},
{
protocol: "https",
hostname: "i.pravatar.cc",
},
2024-12-12 18:38:15 +00:00
{ protocol: "https", hostname: "netidhub.com" },
2024-12-24 12:55:28 +00:00
{
protocol: "https",
hostname: "netidhub.com",
2024-12-24 18:19:39 +00:00
},
2024-11-26 03:09:48 +00:00
],
},
// Bundle optimization
webpack: (config, { dev, isServer }) => {
// Optimize bundle size
if (!dev && !isServer) {
config.optimization.splitChunks = {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
charts: {
test: /[\\/]node_modules[\\/](apexcharts|recharts|chart\.js|react-chartjs-2)[\\/]/,
name: 'charts',
chunks: 'all',
},
maps: {
test: /[\\/]node_modules[\\/](@react-google-maps|leaflet|react-leaflet)[\\/]/,
name: 'maps',
chunks: 'all',
},
},
};
}
return config;
},
// Compression
compress: true,
// Power by header removal
poweredByHeader: false,
// ESLint configuration
2025-01-01 14:10:58 +00:00
// eslint: {
// ignoreDuringBuilds: true,
// },
2024-11-26 03:09:48 +00:00
};
export default bundleAnalyzer(withNextIntl(withNextra(nextConfig)));