Exclude node_modules folder from Laravel Vapor
When you’re working with some CI like Gitlab, you’ll like to cache your node_modules to spend the less amount of time possible.
Here’s an example of a job we’re using to get our frontend dependencies with Yarn:
But… there’s a problem! As we (and most probably you) will have implemented code-splitting on your frontend using Laravel Mix.
Remember that Vapor CLI auto inject the dynamic ASSET_URL to Laravel Mix, here’s how this works.
How can we get the node_modules when we execute vapor deploy command? Easy, at its version 1.13 of their CLI now we can disable the exclusion of node_modules before entering the Vapor’s build hook like this:

That exclude-node-modules: false and adding the node_modules to the ignore so it doesn’t go to your Lambda function. Problem solved!