perf: docker + next.js build optimisation - dockerignore exclusions, BuildKit cache mounts, backend image reuse, memory limits, next.js bundle tree-shaking

This commit is contained in:
2026-09-20 12:03:58 +05:30
parent fee57e154b
commit 896073ea2d
6 changed files with 317 additions and 170 deletions

View File

@@ -11,6 +11,34 @@ const API_BASE =
const nextConfig: NextConfig = {
output: "standalone",
// ── Performance: strip X-Powered-By header ──────────────────────────────
poweredByHeader: false,
// ── Performance: gzip compression handled by Next.js standalone server ──
compress: true,
// ── Compiler optimisations ───────────────────────────────────────────────
compiler: {
// Remove console.log statements from production builds
removeConsole: process.env.NODE_ENV === "production"
? { exclude: ["error", "warn"] }
: false,
},
// ── Tree-shake large packages (only import what is used) ─────────────────
// This tells Next.js to side-effect-free import specific packages,
// significantly reducing the bundle size for heavy libraries.
experimental: {
optimizePackageImports: [
"lucide-react",
"recharts",
"framer-motion",
"date-fns",
],
},
// ── API proxy rewrites ───────────────────────────────────────────────────
async rewrites() {
return [
{