Build Configuration
Version Counter uses Astro’s static site generation. The build configuration is defined inastro.config.mjs:
astro.config.mjs
Key Configuration Options
Site URL
The This is used for:
site property defines your production URL:- Generating absolute URLs in the sitemap
- Social media meta tags
- Canonical links
Integrations
The project uses two Astro integrations:
- @astrojs/react: Enables React components (used for the Counter component)
- @astrojs/sitemap: Automatically generates
sitemap.xmlfor SEO
Building for Production
Install Dependencies
Ensure all packages are installed:The project uses these core dependencies:
package.json
Run the Build
Generate the production build:This command:
- Compiles all
.astrofiles to HTML - Bundles React components with Vite
- Processes Tailwind CSS
- Optimizes images and assets
- Generates the sitemap
dist/ directory.Deployment Platforms
Version Counter can be deployed to any static hosting platform. Here are the most popular options:Netlify (Recommended)
The project is currently deployed on Netlify. It offers:- Automatic deployments from Git
- Free SSL certificates
- Global CDN
- Instant cache invalidation
Connect Repository
- Push your code to GitHub, GitLab, or Bitbucket
- Log in to Netlify
- Click Add new site → Import an existing project
- Select your Git provider and repository
Configure Build Settings
Netlify will auto-detect Astro. Verify these settings:
- Build command:
npm run build - Publish directory:
dist - Node version: 18.x or higher (set in
netlify.tomlor environment variables)
netlify.toml file in your project root:netlify.toml
The redirect rule is necessary for client-side routing, though Version Counter uses server-rendered routes.
Deploy
Click Deploy site. Netlify will:
- Clone your repository
- Run
npm install - Execute
npm run build - Deploy the
dist/folder to the CDN
*.netlify.app subdomain.Vercel
Vercel provides excellent Astro support with zero configuration:Vercel Configuration
Vercel Configuration
Create a
vercel.json for advanced settings:vercel.json
Cloudflare Pages
Cloudflare Pages offers excellent performance with their global edge network:Connect Repository
- Log in to Cloudflare Dashboard
- Go to Workers & Pages → Create application → Pages
- Connect your Git repository
Configure Build
Set these build settings:
- Build command:
npm run build - Build output directory:
dist - Root directory:
/(or your monorepo path)
GitHub Pages
For free hosting on GitHub:Environment Variables
If you need environment variables (for API keys, feature flags, etc.):Performance Optimization
Image Optimization
Image Optimization
Version Counter uses external CDN images. To optimize:
- Use modern formats (WebP, AVIF) when possible
- Compress images before uploading to CDN
- Consider lazy loading for below-the-fold images
- Use responsive images with
srcsetfor different screen sizes
<Image> component:Code Splitting
Code Splitting
Astro automatically splits code by route. For React components:Use
client:visible or client:idle for non-critical components.Caching Strategy
Caching Strategy
Configure cache headers in your hosting platform:Netlify (Vercel (
netlify.toml):vercel.json):Sitemap and SEO
Sitemap and SEO
The
@astrojs/sitemap integration automatically generates a sitemap. Ensure:- The
siteURL inastro.config.mjsis correct - All pages have proper meta tags
- Submit the sitemap to Google Search Console
https://your-domain.com/sitemap.xmlMonitoring and Analytics
Add analytics to track usage:Google Analytics
src/layouts/Layout.astro
Plausible Analytics (Privacy-Friendly)
src/layouts/Layout.astro
Continuous Deployment
Most platforms support automatic deployments:- Push to main branch → Automatic production deploy
- Push to other branches → Deploy preview (Netlify/Vercel)
- Pull requests → Deploy preview for testing
Troubleshooting
Build Failures
Build Failures
Common issues:
- Node version mismatch: Ensure Node 18+ is specified
- Missing dependencies: Check that all packages are in
dependencies(notdevDependencies) - TypeScript errors: Run
npm run buildlocally to catch issues before deploying - Environment variables: Verify all required env vars are set in the platform
Runtime Errors
Runtime Errors
JavaScript not working:
- Check browser console for errors
- Verify React components use correct client directives
- Ensure date strings are in valid ISO 8601 format
- Verify
fecha_inicioandduracion_diasingames.json - Check that Counter component has
client:loaddirective - Test in preview mode before deploying
Performance Issues
Performance Issues
- Use Lighthouse to identify bottlenecks
- Check image sizes and formats
- Review bundle size with
npm run build -- --verbose - Minimize the use of
backdrop-filter(GPU-intensive)
Post-Deployment Checklist
- Verify all pages load correctly
- Test countdown timers are functioning
- Check mobile responsiveness
- Validate sitemap at
/sitemap.xml - Test all game detail pages
- Verify custom domain (if applicable)
- Check SSL certificate is active
- Submit sitemap to search engines
- Set up analytics and monitoring
- Test social media previews (Open Graph)
Next Steps
Adding Games
Learn how to add new games to the dashboard
Customizing Themes
Customize game themes and colors