mickeyfmann's avatar

Cannot Publish Nova Assets in Heroku

I feel like this is becoming a routine issue for us whenever we deploy updates. I undestand that there's no dedicated storage or disk access on Heroku dynos but we're not talking about file uploads here. The issue we keep running into is our compiled front-end assets, js and css files that should be written each and every time the app is deployed.

Originally, we were using Backpack and had the same issue where its public assets were not loading because they weren't being written to the public folder. I was able to get that working by tricking the config for their Basset library. Now, we've switched to Nova and as soon as I deploy, we have the same issue. I've tried manually publishing the Nova assets but nothing is created in the public directory by doing so.

0 likes
2 replies
martinbean's avatar

@mickeyfmann You should publish the assets during the deployment stage. That way, the files will become part of the “slug” that’s ran on dynos.

You can achieve this by adding a compile script to your composer.json file. This will automatically be called by Heroku when you push a new build:

"scripts": {
    // Existing scripts...
    "compile": {
        "@php artisan nova:publish",
        "@php artisan view:clear"
    }
}

Feel free to ping me with any Heroku-related questions. I’ve used Heroku for probably more than 10 years now, so know my way around it 🙂

mickeyfmann's avatar

@martinbean We have it setup to do just that, I've even run the commands manually. Still doesn't actually write them to the public directory. Sorry for the delayed response, was off for the holidays.

Please or to participate in this conversation.