Deploy Laravel (w/ Laravel Mix) Web App in 5 Min on Heroku.
I am using this LinkAce fork in this tutorial. All other Laravel Default should run as-is. For more installation please follow my Other Guide
I was installing an open-source project on Heroku and found Laravel Mix is not working.
So I have time in hand and make it work. It is pretty simple and no prior knowledge is needed. Follow the steps.
I am using free hobby dyno and pgsql for the database.
Update builder pack from Settings > Builderpacks with these two
Note order is necessary for a successful build, drag your Nodejs to the top if PHP already exists.
Update package.json file. Add these lines inside your script section.
“postinstall”: “npm run production”,
Here is my whole script looks like
"postinstall": "npm run production",
"dev": "npm run development",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"test": "npm run production"
Add Procfile to your app
web: vendor/bin/heroku-php-apache2 public/
Step 4. Update your “Config Vars” for deployments
YARN_PRODUCTION : False
Now deploy your app and your laravel mix will run, have fun.
The software I have tested is working with this method is:
For LinkAce you must run these two command from the Heroku terminal to start and use my repo it will bypass the installation file.
php artisan migrate
php artisan registeruser