Dwight Watson's blog

Using Laravel Mix on Heroku

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

Setting up Laravel Mix on Heroku is very similar to how you'd set it up with Elixir. Because Laravel puts your front-end dependencies in devDependencies instead you just need to tweak the default configuration.

First, set YARN_PRODUCTION to false using the following command. This tells Heroku to install the devDependencies in your package.json, but leaves NODE_ENV as production.

$ heroku config:set YARN_PRODUCTION=false

Next, set the engines in your package.json. Make sure you have yarn at least 0.19.1 so that it respects the YARN_PRODUCTION environment variable.

Also add the postinstall key to scripts so that Heroku will compile your assets as you expect after everything has been installed.

{
"engines": {
"node": "7.6.0",
"yarn": "0.21.3"
},
"scripts": {
//
"postinstall": "npm run production"
},
"devDependencies": {
//
"laravel-mix": "^0.8.1"
}
}

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.