Rake Build System

Comprehensive guide to the Rake build system in the Sandbox theme

Understanding Rake

What is Rake?

Rake (Ruby Make) is a build automation tool written in Ruby. In the Sandbox theme, it handles:

  • Development server management
  • Production builds
  • Asset optimization
  • Image processing
  • Task automation

Prerequisites

Required software and dependencies:

  • Ruby (version 2.7.0 or higher)
  • RubyGems
  • Bundler gem
  • ImageMagick or Vips (for image processing)

Windows Installation Guide

Installing ImageMagick on Windows:

  1. Download the appropriate installer:
  2. During installation:
    • Check "Add to system PATH"
    • Check "Install development headers and libraries for C and C++"
    • Check "Install legacy utilities (e.g. convert)"
  3. Verify installation:
    • Open Command Prompt
    • Run magick -version

System Requirements

Windows-specific requirements:

  • Windows 10 or later (recommended)
  • Visual C++ Redistributable 2015-2022
  • Visual Studio Build Tools (for gem installation)
  • At least 2GB free disk space
  • Administrator privileges for installation

Core Functionality

Development Server

The serve task provides a development environment with:

  • Live reload capability
  • Automatic Sass compilation
  • Vendor file processing
  • Asset watching

Production Build

The build task creates production-ready assets:

  • Minified CSS and JavaScript
  • Optimized images
  • Compiled Jekyll site
  • Environment-specific configurations

Image Processing

WebP Conversion

Automated image optimization features:

  • Batch conversion to WebP format
  • Original file preservation options
  • Size optimization reporting
  • Configurable quality settings

Best Practices

Development Workflow

Recommended development workflow:

  1. Start development server: bundle exec rake serve
  2. Make changes to source files
  3. Test in development environment
  4. Optimize images if needed
  5. Build for production: bundle exec rake build

Performance Tips

Optimize build performance:

  • Use incremental builds during development
  • Process images in batches
  • Maintain clean asset directories
  • Regular cache clearing

Troubleshooting

Common Issues

Solutions for frequent problems:

  • Missing Dependencies: Run bundle install
  • Port Conflicts: Change port in configuration
  • Build Failures: Check error logs and Jekyll environment
  • Image Processing Errors: Verify ImageMagick installation

Debugging

Debug Rake tasks:

  • Enable verbose mode: rake -v task_name
  • Check Jekyll logs in _site/build.log
  • Use --trace flag for detailed stack traces
  • Monitor system resources during builds

Advanced Usage

Custom Tasks

Create custom Rake tasks in Rakefile:

Command Reference

Available Commands

Command Description Usage
serve Start development server bundle exec rake serve
build Build for production bundle exec rake build
convert_to_webp Convert images to WebP bundle exec rake convert_to_webp
optimize_images Convert and optionally remove originals bundle exec rake optimize_images[true]
prepare Run preparation tasks bundle exec rake prepare
remove_originals Remove original images bundle exec rake remove_originals