Skip to content

Instantly share code, notes, and snippets.

@olizilla
Last active December 13, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olizilla/4971528 to your computer and use it in GitHub Desktop.
Save olizilla/4971528 to your computer and use it in GitHub Desktop.
How to Node, NPM, Grunt, Git and Heroku

Problem: I'd prefer not to commit compiled resources to my repository, but I've still gotta deploy the thing.

Simple solution: Commit compiled resources...

Bonus credit solution: npm postinstall task runs grunt, grunt creates the compiled resources, heroku can then automagic on git push, rainbows and unicorns ensue.1,2

Your milage may vary, but on the happy path a git push heroku can deploy and run your node app.

Getting grunt to do your bidding is covered elsewhere. GRUNTEND is a fine bootstrap to getting your HTML5 Boilerplate app rolling on grunt: https://github.com/alanshaw/gruntend

1: I had to tell Heroku which node engine and npm version to use, via the engines property of the package.json. Specifying dependencies, however far up the foodchain they may be, rather than committing them all is the point of the exercise, so all is well.

2: Grunt recommends installing globally, but this solution is only likely to work if you let npm install a local grunt before trying to run it. I can live with that. For now.

{
"author": "olizilla",
"Your preamble goes": "here"
"scripts": {
"postinstall": "echo postinstall time; ./node_modules/grunt/bin/grunt"
},
"dependencies": {
"grunt":"~0.3.17",
"grunt-contrib": "~0.3.0",
"grunt-include-replace":"0.0.0-beta",
"express": "3.x",
"handlebars": "~1.0.8",
"consolidate": "~0.8.0"
},
"engines": {
"node": ">=0.8",
"npm": "1.1.x"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment