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.
1.8 KiB
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:
- Memory Limit Control: Sets Node.js memory limit to prevent crashes on memory-constrained systems
- Build Cache Management: Automatically cleans up caches to prevent bloat
- TypeScript/ESLint Skip: Skips type checking and linting during production builds
- Code Splitting: Implements React.lazy() for code splitting and lazy loading
- 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:
- Try running with lower memory settings
- Disable unnecessary parts of the app temporarily
- Build incrementally using
next build --no-lint