I found two ways to make this work.
Heroku Node Custom Buildpack
Use the mbuchetics assembly of Heroku. This works mainly by rebuilding the application when it was ported to Heroku.
There were several tricks that I had to use to do this job. In Gruntfile.js , two new tasks had to be set up: heroku:production and heroku:development . This is what buildpack does to build the application. At first, I just overlaid the main build task, but found that either buildpack or Heroku had a problem launching jshint , so in the end I copied the build task and got the parts that I don’t need.
Also in packages.json I had to add this:
"scripts": { "postinstall": "bower cache clean && bower install" }
This made bower_components available in Heroku.
Pros
This allowed me to save the .gitignore file tactfully so that the “binaries” in the dist directory and the dependencies in the bower_components directory bower_components not transferred to the original control.
Against
This is basically a rebuild of the application when it is on Heroku, and I usually prefer to use the same “binaries” throughout the assembly and deployment pipeline. Thus, I know that the same code that was built is the same code that was tested and the same code that was deployed.
It also slows down the deployment, as you have to wait until the application is created twice.
Implement CodeShip Script
Not satisfied that I was building my application twice, I tried to use the Script pipeline in CodeShip instead of the existing Heroku. Script basically modified the .gitignore file to allow the creation of a dist folder, and then clicked on the Heroku remote (which leaves the code on the origin remote unaffected by the change).
I ended up with a bash script:
#!/bin/bash gitRemoteName="heroku_$APP_NAME" gitRemoteUrl=" git@heroku.com :$APP_NAME.git"
Pros
This requires only one build of the application and deployment of the same binaries that were tested during the testing phase.
Against
I have used this Script quite a few times and it seems relatively stable. However, one of the problems that I know about is that when creating a new pipeline there will be no code on the master branch, so this Script fails when it tries to merge with the remote Heroku pool. Right now, I will get around this by doing the initial push of the master branch in Heroku before starting the build, but I think there might be a better Git command that I could execute line by line; "only merge this branch if it already exists."