Files
ember-market-frontend/docs/OPTIMIZED-BUILD.md
NotII 5ce716d2ab Refactor docs structure and update API env config
Moved documentation files into a new docs/ directory and added a documentation index (docs/README.md). Updated the main README with improved project and documentation details. Set explicit API environment variables in Dockerfile for production. Enhanced next.config.mjs with improved API_BASE_URL handling and logging for better deployment clarity.
2025-09-01 16:48:42 +01:00

1.8 KiB

Optimized Builds for Slower CPUs

This document provides instructions for building the project on slower CPUs or resource-constrained environments.

Quick Start

Run the optimized build using:

npm run build:optimized

Optimization Features

The following optimizations have been implemented to improve build performance:

  1. Memory Limit Control: Sets Node.js memory limit to prevent crashes on memory-constrained systems
  2. Build Cache Management: Automatically cleans up caches to prevent bloat
  3. TypeScript/ESLint Skip: Skips type checking and linting during production builds
  4. Code Splitting: Implements React.lazy() for code splitting and lazy loading
  5. Source Map Disabling: Disables source maps in production for faster builds

Manual Optimization Steps

If you need to manually optimize the build process:

1. Clean the caches

npm run clean

2. Set Node.js memory limit

export NODE_OPTIONS="--max-old-space-size=4096"

3. Skip non-essential checks

NEXT_SKIP_LINT=1 NEXT_SKIP_TS_CHECK=1 npm run build

4. Use SWC compiler with optimized settings

NEXT_TELEMETRY_DISABLED=1 npm run build:fast

Configuration Files

The following configuration files have been optimized:

  • next.config.mjs: Contains SWC optimizations and standalone output
  • .npmrc: Configures Node.js memory limits and disables notifications
  • .env.production: Sets environment variables for production builds

Troubleshooting

Out of Memory Errors

If you encounter "JavaScript heap out of memory" errors, try:

export NODE_OPTIONS="--max-old-space-size=2048"
npm run build:fast

Slow Builds

If builds are still slow:

  1. Try running with lower memory settings
  2. Disable unnecessary parts of the app temporarily
  3. Build incrementally using next build --no-lint