Skip to content
This repository

The following deployment guide is useful for developers wishing to publish or deploy a specific directory (e.g dist) to GitHub pages or another production server.

In a typical project scaffolded with yo, grunt build will generats an optimized version of your application in the dist directory. There are multiple ways to version and deploy this code to production.

Grunt-build-control task

Grunt build control has been developed specifically to deploy Yeoman applications. It helps you version and deploy built code automatically with a grunt task. Configuration options include:

  • The name of the branch to commit to (e.g., prod, gh-pages)
  • The remote to push to (e.g., a Heroku instance, a GitHub remote, or the local source code repo)
  • Automatic commit messages including the branch and commit the code was built from
  • Safety checks to make sure the source repository is clean, so that built code always corresponds to a source code commit

Build control fetches prior to every commit and in general does a pretty good job of keeping code well versioned when with multiple contributors are deploying independently. It maintains full revision history as long as no user force pushes. Complete documentation is available at the project's GitHub page.

Git subtree command

You can also maintain the source and built code on the same branch, and deploy only the dist directory with the git subtree command.

  1. Remove the dist directory from the .gitignore file. Yeoman projects ignore it by default.
  2. Add the dist directory to your repository:

    git add dist && git commit -m "Initial dist subtree commit"
    
  3. Deploy the subtree to a different branch. Specify a relative path to your dist directory with --prefix:

    git subtree push --prefix dist origin gh-pages
    
  4. Develop normally, committing your entire repository to your default (master) branch.

  5. To deploy the dist directory, run the subtree push command from the root directory:

    git subtree push --prefix dist origin gh-pages
    

Git-directory-deploy script

Git directory deploy is a less-automated script that works on similar principles to grunt build control.

Further reading

Something went wrong with that request. Please try again.