The previous version of this gist claimed php artisan optimize should be moved from build to deploy because cached views/routes contain wrong file paths. That's incorrect. Cached Blade views only contain path references in PHP comments (/**PATH ... ENDPATH**/), not in executable code. Laravel resolves paths dynamically at runtime.
Moving optimize to deploy actually breaks the deploy because Lambda's /var/task is read-only and event:cache/view:cache can't write there.
The standard Vapor template (optimize in build) is correct. Don't change it.