0

How do I execute custom build script when deploying node.js application to Heroku?

For example, I want to minify JavaScript files.

shengmin
  • 319
  • 1
  • 3
  • 13
  • 2
    Take a look at http://stackoverflow.com/a/13796081. The question is about using `grunt` with Heroku, but the answer is generalized. Though, [`grunt`](http://gruntjs.com/) can help [with the build step](https://npmjs.org/package/grunt-contrib-uglify). – Jonathan Lonowski Jul 28 '13 at 01:47
  • why don't you do that before deploying? – Jonathan Ong Jul 28 '13 at 05:56
  • @JonathanOng: I could, but from my understanding of how Heroku deployment/Git works, I need to create a separate Git repo just for deployment so I can push the deployment repo to Heroku. – shengmin Jul 29 '13 at 22:48

1 Answers1

0

I highly recommend the use of asset-rack, which will minify files when your server first starts up, as well as providing fingerprinted versions of the files that can be cached forever.

https://github.com/techpines/asset-rack

Dan Kohn
  • 33,811
  • 9
  • 84
  • 100
  • Thanks, but JavaScript minification is just one particular thing I need to perform. I need a more general solution that allows me to perform any custom build steps. – shengmin Jul 28 '13 at 21:46
  • Grunt is the best tool for any number of build steps. But take a look at asset-rack. It support browserify and other useful steps, and you may not need grunt after all. – Dan Kohn Jul 29 '13 at 00:42