Skip to content

Commit d48a4e5

Browse files
Performance optimization completed
1 parent 3af8933 commit d48a4e5

18 files changed

Lines changed: 736 additions & 343 deletions

next.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import type { NextConfig } from "next";
22

3+
// Bundle analyzer for monitoring code splitting
4+
const withBundleAnalyzer = require("@next/bundle-analyzer")({
5+
enabled: process.env.ANALYZE === "true",
6+
});
7+
38
const nextConfig: NextConfig = {
49
images: {
510
remotePatterns: [
@@ -10,6 +15,15 @@ const nextConfig: NextConfig = {
1015
],
1116
// Optimize images for faster loading
1217
formats: ["image/avif", "image/webp"],
18+
// Enable image optimization
19+
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
20+
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
21+
// Minimize quality for faster loading
22+
minimumCacheTTL: 60,
23+
// Use sharp for better performance
24+
dangerouslyAllowSVG: true,
25+
contentDispositionType: "attachment",
26+
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
1327
},
1428
headers: async () => {
1529
return [
@@ -62,6 +76,11 @@ const nextConfig: NextConfig = {
6276
},
6377
];
6478
},
79+
// Enable experimental optimizations
80+
experimental: {
81+
// Optimize package imports to reduce bundle size
82+
optimizePackageImports: ["lucide-react", "@radix-ui/react-icons"],
83+
},
6584
};
6685

67-
export default nextConfig;
86+
export default withBundleAnalyzer(nextConfig);

package-lock.json

Lines changed: 154 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dev": "next dev",
77
"dev:webpack": "NEXT_PRIVATE_WEBPACK_BUILD=1 next dev",
88
"build": "prisma generate && next build",
9+
"build:analyze": "cross-env ANALYZE=true npm run build",
910
"start": "next start",
1011
"lint": "next lint",
1112
"lint:fix": "next lint --fix",
@@ -88,11 +89,13 @@
8889
"sonner": "^2.0.5",
8990
"swagger-ui-dist": "^5.29.5",
9091
"swagger-ui-react": "^5.29.5",
92+
"swr": "^2.3.8",
9193
"tailwind-merge": "^3.2.0",
9294
"tw-animate-css": "^1.2.5",
9395
"zod": "^3.25.76"
9496
},
9597
"devDependencies": {
98+
"@next/bundle-analyzer": "^16.1.1",
9699
"@playwright/test": "^1.56.1",
97100
"@tailwindcss/postcss": "^4",
98101
"@testing-library/jest-dom": "^6.9.1",

src/app/api-docs/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useEffect, useState } from "react";
4-
import SwaggerUI from "swagger-ui-react";
4+
import { SwaggerUIComponent } from "@/components/dynamic-imports";
55
import "swagger-ui-react/swagger-ui.css";
66

77
/**
@@ -69,7 +69,7 @@ export default function ApiDocsPage() {
6969

7070
return (
7171
<div style={{ padding: 0, margin: 0 }}>
72-
<SwaggerUI spec={spec} persistAuthorization={true} />
72+
<SwaggerUIComponent spec={spec} persistAuthorization={true} />
7373
</div>
7474
);
7575
}

src/app/layout.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "@/app/globals.css";
44
import "@/lib/prisma-middleware-trial";
55
import { Toaster } from "sonner";
66
import { SidebarProvider } from "@/components/ui/sidebar";
7+
import { SWRProvider } from "@/components/providers/swr-provider";
78

89
// Optimize font loading - prevents layout shift
910
const inter = Inter({
@@ -33,9 +34,11 @@ export default function RootLayout({
3334
<html lang="en" className={inter.className}>
3435
<body className="antialiased">
3536
<Toaster position="bottom-right" />
36-
<SidebarProvider>
37-
<main className="h-screen w-screen">{children}</main>
38-
</SidebarProvider>
37+
<SWRProvider>
38+
<SidebarProvider>
39+
<main className="h-screen w-screen">{children}</main>
40+
</SidebarProvider>
41+
</SWRProvider>
3942
</body>
4043
</html>
4144
);

src/app/mentors/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function MentorsLoading() {
1313
);
1414
}
1515

16-
// Enable dynamic rendering with reasonable revalidation
17-
export const dynamic = "force-dynamic";
18-
export const revalidate = 60; // Revalidate every 60 seconds
16+
// Enable ISR (Incremental Static Regeneration) instead of force-dynamic
17+
// This pre-renders the page and revalidates in the background
18+
export const revalidate = 300; // Revalidate every 5 minutes
1919

2020
const Mentorsection = () => {
2121
return (

src/app/pricing/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import PlansDashboard from "@/components/dashboard/plans-dashboard";
22

3+
// Enable static generation for pricing page
4+
// This page doesn't change often, so we can pre-render it
5+
export const dynamic = "force-static";
6+
export const revalidate = 3600; // Revalidate every hour
7+
38
export default function PricingPage() {
49
return (
510
<div className="flex flex-col items-center justify-center bg-gray-50">

src/components/dashboard/mentor/sections/diet-plans-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useState, useEffect } from "react";
44
import { useForm } from "react-hook-form";
55
import { zodResolver } from "@hookform/resolvers/zod";
66
import { z } from "zod";
7-
import { DietPlanEditor } from "@/components/editor/DietPlanEditor";
7+
import { DietPlanEditor } from "@/components/dynamic-imports";
88
import { Button } from "@/components/ui/button";
99
import { Input } from "@/components/ui/input";
1010
import { Textarea } from "@/components/ui/textarea";

0 commit comments

Comments
 (0)