Experimental!! A high-performance static content deployment tool written in Go that significantly accelerates Magento 2 static asset deployment by leveraging true parallelization and efficient file I/O.
On this project, deployment improved from ~115 seconds (Magento native) to ~0.3-0.5 seconds for the frontend theme deployment:
- Vendor/Hyva/frontend: 11,126 files deployed in 0.3 seconds
- Throughput: ~40,000 files/second
- Speedup: 230-380x faster than PHP implementation
- Native Parallelization: Go's goroutines handle true concurrent I/O across multiple CPU cores
- Low Overhead: No PHP bootstrap, no Magento dependency injection, no database access
- Efficient I/O: Optimized file copying with buffered I/O and minimal memory allocation
- Simple Logic: Deployment doesn't require PHP preprocessing (LESS compilation, etc. handled by NPM)
cd tools/magento2-static-deploy
go build -o magento2-static-deploy main.go watcher.go- Go 1.21 or later
Deploy Vendor/Hyva theme to frontend area:
./tools/magento2-static-deploy/magento2-static-deploy \
-root . \
-locales nl_NL \
-themes Vendor/Hyva \
-areas frontend./tools/magento2-static-deploy/magento2-static-deploy \
-root . \
-locales nl_NL,en_US \
-themes Vendor/Hyva \
-areas frontend \
-jobs 8 \
-vBy default, only frontend area is deployed. This is because:
- Admin themes (Magento/backend, MageOS/m137-admin-theme) are part of Magento core
- They don't typically need custom deployment unless you have custom admin theme
- If deployment encounters a missing theme, it gracefully skips it
To deploy admin themes if they exist:
./magento2-static-deploy -areas frontend,adminhtml -v -root string
Path to Magento root directory (default ".")
-locales string
Comma-separated locales (default "nl_NL")
Example: nl_NL,en_US,de_DE
-themes string
Comma-separated themes (default "Vendor/Hyva")
Example: Vendor/Hyva,Magento/blank,Hyva/reset
-areas string
Comma-separated areas (default "frontend,adminhtml")
Options: frontend, adminhtml
-jobs int
Number of parallel jobs (default 0 = auto-detect CPU count)
Use -jobs 1 for sequential processing
-strategy string
Deployment strategy (default "quick")
Note: Currently only copies files; strategy is informational
-force
Force deployment even if files exist (always copies)
-v Verbose output showing per-deployment progress
./magento2-static-deploy -root /var/www/magento -locales nl_NL -themes Vendor/Hyva -areas frontend./magento2-static-deploy \
-locales nl_NL,en_US,de_DE \
-themes Vendor/Hyva,Magento/blank \
-areas frontend./magento2-static-deploy -jobs 1 -v./magento2-static-deploy \
-locales nl_NL \
-themes Vendor/Hyva \
-areas frontend,adminhtml-
Creates combinations of (locale, theme, area)
-
For each combination:
- Verifies source theme directory exists
- Creates destination directory in
pub/static - Recursively copies all files from source to destination
- Counts files deployed
-
Processes jobs in parallel using goroutines
-
Reports results with timing and throughput metrics
This version performs pure file copying. The following are handled separately:
- LESS/SCSS Compilation: Done by Hyva theme's npm build process
- JavaScript Minification: Done by npm/webpack
- CSS Minification: Done by build tools
- Symlink Fallback: Not implemented
- Admin Theme Deployment: Skipped if theme doesn't exist (Magento core themes don't need custom deployment)
- Vendor Theme Path Resolution: Gracefully skips themes not found in app/design or vendor paths
- Requires full Magento bootstrap
- Single-threaded or limited parallelization
- PHP overhead for each file
- ~115 seconds for 28,500 files
- Direct file operations
- True goroutine-based parallelization
- Minimal overhead per file
- ~0.3-0.5 seconds for 11,126 files
-
Development: Use Hyva theme's npm build and cache-clean watch
npm --prefix app/design/frontend/Vendor/Hyva/web/tailwind run dev
-
Deployment Prep: Run this tool to stage static files
./magento2-static-deploy -v
-
Cache Clear (if needed):
bin/magento cache:clean
Current version:
- ✓ Simple, fast file copying
- ✓ Parallel processing
- ✓ Multi-locale/theme support
- ✓ Verbose progress reporting
Not yet implemented:
- LESS/SCSS compilation (use npm instead)
- JavaScript bundling (use npm instead)
- Content version management
- Symlink fallback strategy
- Incremental deployment detection
- CDN push notifications
- File checksums/integrity checks
main.go: CLI interface, orchestration logicwatcher.go: File change detection (for future watch mode)
go build -o magento2-static-deploy main.go watcher.gotime ./magento2-static-deploy -vSince this tool only copies files, it integrates well with existing Magento setups:
- Hyva theme builds are done via npm
- Static files are copied to pub/static by this tool
- Cache can be cleared separately as needed