Overview
Proper environment configuration ensures ESBO Web runs consistently across development, staging, and production environments. This guide covers Node.js requirements, environment variables, and configuration for different deployment targets.Node.js Requirements
Version Compatibility
ESBO Web requires:- Node.js: 18.0.0 or higher (recommended: 18.x LTS or 20.x LTS)
- npm: 9.0.0 or higher (comes with Node.js)
Vite 7.3.1 requires Node.js 18+ for optimal performance and ES module support.
Checking Your Version
Verify your current Node.js version:Installing Node.js
Direct Installation
Download from nodejs.org:
- Choose LTS (Long Term Support) version
- Follow installer instructions
- Verify installation with
node --version
Environment Variables
Vite Environment Variables
Vite exposes environment variables to your client-side code using theVITE_ prefix.
Currently, ESBO Web doesn’t require environment variables for basic functionality. However, you may need them for API integrations or feature flags.
Creating Environment Files
Create environment files in your project root:Environment File Priority
Vite loads environment files in this order (later files override earlier ones):.env- Loaded in all cases.env.local- Loaded in all cases, ignored by git.env.[mode]- Loaded only in specified mode.env.[mode].local- Loaded only in specified mode, ignored by git
Using Environment Variables
Access environment variables in your code:Built-in Variables
Vite provides these variables automatically:import.meta.env.MODE:'development'or'production'import.meta.env.PROD:truein productionimport.meta.env.DEV:truein developmentimport.meta.env.BASE_URL: Base URL of the app
Development vs Production
Development Environment
Start development server:- Runs on
http://localhost:5173 - Hot Module Replacement (HMR) enabled
- Verbose error messages
- Source maps included
- No optimization or minification
- Fast rebuild times
Production Environment
Build for production:- Optimized and minified bundles
- Tree-shaking applied
- Asset hashing for cache busting
- No development warnings
- Optimized for performance
Preview Production Locally
Test production build on local machine:The preview server runs on
http://localhost:4173 by default and serves the built dist/ directory.Deployment Target Configuration
Vercel
Automatic configuration (detected by Vercel):- Framework: Vite
- Build Command:
npm run build - Output Directory:
dist - Node.js Version: 18.x (default)
- Go to Project Settings → Environment Variables
- Add variables with
VITE_prefix - Select environments: Production, Preview, Development
- Redeploy to apply changes
Vercel automatically makes environment variables available during build time.
Netlify
Build settings:netlify.toml
- Add in Site Settings → Environment Variables
- Use
VITE_prefix for client-side variables
GitHub Pages
Configure base path invite.config.js:
vite.config.js
.github/workflows/deploy.yml
Docker
Multi-stage Dockerfile:Dockerfile
nginx.conf
Configuration Best Practices
Security
Safe for client-side:Git Ignore Configuration
Ensure your.gitignore includes:
.gitignore
Type Safety for Environment Variables
Create type definitions for environment variables:vite-env.d.ts
Troubleshooting
Environment Variables Not Loading
Node.js Version Mismatch
If you encounter version issues:Build Fails in CI/CD
Most CI/CD issues are caused by missing environment variables or incorrect Node.js versions.
- Verify Node.js version in CI configuration
- Ensure all required environment variables are set
- Check that build command matches
package.json - Verify dependencies are installed correctly
- Review build logs for specific errors
Next Steps
- Set up environment-specific configurations
- Configure deployment pipelines
- Add monitoring and analytics
- Implement feature flags
- Set up automated testing across environments