How to run “grunt build” during Heroku deployment (angular and ruby-on-rails app)

I’d like to deploy an angular+rails app on Heroku. The app is built off Emmanual Oda’s example code, and compiles its assets using Grunt.

Instead of compiling my assets locally and then committing them to git, I’d prefer to compile them on Heroku. That is, I’d like to run grunt build on Heroku automatically whenever my app is deployed.

  • Nodejs. gulp not found after npm install
  • Nice Git architecture for server / client?
  • How to handle backend (laravel) and frontend (angular) dependencies in different git repos
  • Bower install: No versions available
  • Heroku Deploy Error: Cannot find module './errors/cast'
  • In Git for Windows Bash, how to install “get-apt” and “sudo” and all those basic commands?
  • Does anyone know how I can configure Heroku to do this?


    I know server side asset compilation is possible with Node.js apps, for example using mbuchetics’ fork of the heroku nodejs buildpack. When I follow the instructions at that site and push to Heroku, though, I get the following error

    -----> Fetching custom git buildpack... done
     !     Push rejected, no Cedar-supported app detected

    EDIT 2

    For the time being I’m deploying using a Rake task that runs grunt build locally.

    task :deploy do
      system("rm -rf ./public/*")       # empty the public directory
      system("cd ngapp; grunt build")
      # make a bogus manifest file to turn off asset compilation on heroku 
      #   see here:
      system("mkdir public/assets; touch public/assets/manifest-098f6bcd4621d373cade4e832627b4f6.json")  
      system("git add public/")
      system("git commit -m \"deploying...\"")
      system("git push heroku master")

    A server side solution would be preferable!

  • jspm install can't download packages from npm and github due to proxy settings
  • How to resync git with svn tree?
  • Using Github interface for single commit pull request
  • How can I use AC_REVISION with Git?
  • Composer autoload-dev does not work
  • Using git, how do you move some uncommitted changes from one branch to another branch in a different folder?
  • 2 Solutions collect form web for “How to run “grunt build” during Heroku deployment (angular and ruby-on-rails app)”

    I believe this is what you want:

    This solution uses multi buildpacks to run grunt build in production. No build artifacts in version control.

    My project is also based off of that sample rails app structure. May I ask why you want heroku to compile your grunt build rather than committing it? Having heroku compile it means even longer deploy times. What I do is I have a deploy script run grunt build and also run all the tests before committing to a build branch. That build branch is pushed to heroku. That way my development branch stays clean without the compiled assets in the public folder.

    Git Baby is a git and github fan, let's start git clone.