How to deploy node app that uses grunt to heroku

前端 未结 7 2150
悲哀的现实
悲哀的现实 2020-11-29 17:20

I\'m using grunt and also grunt plugins like grunt-contrib-copy, grunt-contrib-mincss (that listed as npm dependencies for my application).

7条回答
  •  孤独总比滥情好
    2020-11-29 17:46

    This looks like it will largely be solved when the Heroku Platorm API slug and release features make it into the mainline. At that point, you can build your code locally (or on a ci server), package it up and send it to heroku via an API call and release it from there.

    This is still in the beta period and was only announced on December 19, 2013.

    https://devcenter.heroku.com/articles/platform-api-deploying-slugs

    I was never super happy with how many people seemed ok with checking in your generated code into git or the NPM postinstall hook. :(

    Plus from a philosophical stance, doing a build during a release is simply another potential failure point.


    Just for fun: Since that's not finalized yet, here's a bash script I threw together you can use for the time being to build your code on a deployment branch, commit it, deploy it to heroku and then remove the deployment branch. (I really am not a fan of bash deployment scripts, so I'm really looking forward to the platform API additions)

    #!/bin/bash
    set -e 
    
    # Delete current deploy branch
    git branch -D deploy
    # Create new deploy branch based on master
    git checkout -b deploy
    # Grunt comands to build our site
    grunt build:production
    # the dist/ directory is in my .gitignore, so forcibly add it
    git add -f dist/
    git commit -m "Deploying to Heroku"
    # Push it up to heroku, the -f ensures that heroku won't complain
    git push heroku -f deploy:master
    # Switch it back to master
    git checkout master
    

提交回复
热议问题