Don't forget to require fs somewhere at the top of your mix file!
If this looks a little scary, don't worry. Just replace my details with your own username/site name to match up to the key and certificate. **Really importantly **we'll tidy this up later to avoid issues in production, so read on!
Ok, with that config added. Let's check it out.
Nice! We're successfully loading in those two assets (and any more you add in future).
What about production?
When you deploy this app (and run npm run prod), these configuration options will be included, which may cause issues.
To avoid this, we'll make use of Laravel Mix's built-in production check.
It's really up to you. Just make sure you differentiate between your development and production environments. You could even create a separate mix.config.js file for each environment. For something this simple, a couple of IF statements do the trick.
Bonus! Hiding your key and certificate paths.
Your mix.config.js file will always be pushed to source control, so it makes sense to control the path through your .env file (which should not be pushed to production). This also makes it really easy for another developer to specify their own paths when working on their machine!
Start by requiring in dotenv at the top of your mix file.
Now add the environment variables to your .env file.