Build Process
The production build process includes several automated steps:Install Dependencies
Install all required packages using npm:If you encounter dependency conflicts, use the legacy peer deps flag:
Run Pre-Generation Scripts
The build automatically runs pre-generation scripts that:
- Copy contract addresses from configuration
- Generate required build-time assets
Build for Production
Create an optimized production build:This command:
- Runs
postinstallhooks (Husky and address copying) - Executes pre-generation scripts
- Builds Next.js with standalone output mode
- Generates
.next/standalonedirectory with minimal dependencies
Build Configuration
The production build is configured innext.config.js with the following key settings:
Standalone Output
next.config.js
Environment Variables
Environment variables must be set at build time for Next.js public variables.Build Artifacts
After a successful build, you’ll have:.next/standalone/- Minimal server with dependencies.next/static/- Static assets (CSS, JS, images)public/- Public static files
Build Scripts
The following npm scripts are available:Static Export
For fully static deployment without a Node.js server:public/ directory with exported static HTML files. Note that some dynamic features may not work in static export mode.
Environment Requirements
The application requires Node.js version 22 as specified in
package.json.Required Environment Variables
Set these before building:.env
Optional Configuration
.env
Build Optimization
The Next.js configuration includes several optimizations:- Output file tracing - Automatically determines minimal dependencies
- SVG optimization - SVGs are processed with SVGR for React components
- Webpack 5 - Modern bundling with improved tree-shaking
- Standalone mode - Self-contained server with minimal footprint
Troubleshooting
Build Fails with Module Errors
If you see module resolution errors:Missing Environment Variables
If the build completes but the app doesn’t work:- Check that all
NEXT_PUBLIC_*variables are set - Rebuild after adding variables
- Verify variables are not empty strings
Out of Memory Errors
For large builds, increase Node.js memory:Next Steps
Docker Deployment
Deploy using containerization
Hosting Options
Deploy to Netlify, Vercel, or S3