Skip to content

Command Line Tools

Asset Management Commands

The Wheels CLI provides commands for managing static assets in your application, including compilation, optimization, and cleanup of JavaScript, CSS, and image files.

Terminal window
wheels assets precompile
wheels assets clean
wheels assets clobber

Prepares your assets for production deployment by minifying and optimizing them.

Terminal window
# Basic precompilation (defaults to production)
wheels assets precompile
# Force recompilation of all assets
wheels assets precompile --force
# Target specific environments (with aliases)
wheels assets precompile --environment=production # Full minification
wheels assets precompile --environment=prod # Alias for production
wheels assets precompile --environment=staging # Light minification
wheels assets precompile --environment=stage # Alias for staging
wheels assets precompile --environment=testing # Light minification
wheels assets precompile --environment=test # Alias for testing
wheels assets precompile --environment=maintenance # Light minification
wheels assets precompile --environment=development # No minification
wheels assets precompile --environment=dev # Alias for development

The command applies different levels of asset optimization based on the target environment:

  • Production (production, prod): Full minification - Maximum compression, removes all comments and whitespace, optimizes code structure
  • Staging (staging, stage): Light minification - Removes comments and excessive whitespace but preserves some formatting for debugging
  • Testing (testing, test): Light minification - Same as staging, optimized for testing environments
  • Maintenance (maintenance): Light minification - Minimal processing for maintenance mode deployments
  • Development (development, dev): No minification - Preserves original formatting and comments for debugging
  • Minifies JavaScript files: Removes comments, whitespace, and unnecessary characters (level depends on environment)
  • Minifies CSS files: Removes comments, whitespace, and optimizes CSS rules (level depends on environment)
  • Generates cache-busted filenames: Adds MD5 hashes to filenames (e.g., application-a1b2c3d4.min.js)
  • Creates manifest.json: Maps original filenames to compiled versions
  • Processes images: Copies images with cache-busted names
  • Output location: Stores all compiled assets in /public/assets/compiled/
{
"application.js": "application-a1b2c3d4.min.js",
"admin.js": "admin-b2c3d4e5.min.js",
"styles.css": "styles-c3d4e5f6.min.css",
"admin.css": "admin-d4e5f6g7.min.css",
"logo.png": "logo-e5f6g7h8.png",
"banner.jpg": "banner-f6g7h8i9.jpg"
}

Removes old compiled assets while keeping recent versions for rollback capability.

Terminal window
# Clean old assets (keeps 3 most recent versions by default)
wheels assets clean
# Keep 5 versions of each asset
wheels assets clean --keep=5
# Preview what would be deleted without actually deleting
wheels assets clean --dryRun
  • Identifies old versions: Finds all compiled assets with hash fingerprints
  • Keeps recent versions: Retains the specified number of most recent versions (default: 3)
  • Removes old files: Deletes older versions to free disk space
  • Updates manifest: Ensures manifest.json remains current
  • Dry run option: Preview deletions without making changes

Completely removes all compiled assets and the manifest file.

Terminal window
# Remove all compiled assets (with confirmation prompt)
wheels assets clobber
# Skip confirmation prompt
wheels assets clobber --force
  • Deletes compiled directory: Removes /public/assets/compiled/ and all contents
  • Removes manifest: Deletes the manifest.json file
  • Confirmation prompt: Asks for confirmation unless —force is used
  • Complete cleanup: Useful for fresh starts or troubleshooting
  1. Before deployment:
Terminal window
# Compile assets for production
wheels assets precompile --environment=production
# Clean old versions to save space
wheels assets clean --keep=3
  1. After deployment verification:
Terminal window
# If rollback needed, previous versions are still available
# If deployment successful, further cleanup can be done
wheels assets clean --keep=2

During development, you typically don’t need compiled assets:

Terminal window
# Remove all compiled assets in development
wheels assets clobber --force
# Precompile only when testing production builds
wheels assets precompile --environment=development

Example CI/CD pipeline step:

.github/workflows/deploy.yml
- name: Compile Assets
run: |
wheels assets precompile --environment=production
wheels assets clean --keep=3

After running wheels assets precompile:

/public/
/assets/
/compiled/
manifest.json
application-a1b2c3d4.min.js
styles-e5f6g7h8.min.css
logo-i9j0k1l2.png
/javascripts/
application.js (original)
/stylesheets/
styles.css (original)
/images/
logo.png (original)

Configure asset handling in your Wheels application:

config/settings.cfm
// Enable asset fingerprinting in production
set(useAssetFingerprinting = true);
// Set asset cache duration (in minutes)
set(assetsCacheMinutes = 1440); // 24 hours
// Define assets path
set(assetsPath = "/assets");
Terminal window
# Force recompilation
wheels assets precompile --force
# Verify manifest exists and is current
cat public/assets/compiled/manifest.json
Terminal window
# Check space used by compiled assets
du -sh public/assets/compiled/
# Aggressive cleanup - keep only 1 version
wheels assets clean --keep=1
# Or remove everything and recompile
wheels assets clobber --force
wheels assets precompile
Terminal window
# Ensure assets were compiled for the correct environment
wheels assets precompile --environment=production
# Check that manifest.json exists
ls -la public/assets/compiled/manifest.json
  • Backup: Always backup assets before running clobber in production
  • Version Control: Don’t commit compiled assets to version control
  • Deployment: Run precompile as part of your deployment process
  • Performance: Compiled assets significantly improve load times
  • Cache Busting: Hash fingerprints ensure browsers load updated assets