General Assembly Logo

Ember Deployment Guide

Use this guide to deploy Ember apps based on our Ember Template to GitHub Pages.

Prerequisites

Objectives

By the end of this, developers should be able to:

  • Deploy an Ember app to GitHub Pages

Deployment to Github

  1. If you haven't already, run npm install and bower install.
  2. Make sure that everything is named consistently (i.e. ember-template -> <% NAME OF YOUR CLIENT %>). (Search via command+shift+f)
  3. You need tell your Ember client to point to your deployed API. Update config/environment.js to follow below:
module.exports = function(environment) {
  var ENV = {
    modulePrefix: '<% NAME OF YOUR CLIENT will be here %>',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    apiHost: 'http://localhost:3000/',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

Yes, use var, not let for ENV.

AND FURTHER DOWN IN config/environment.js:

if (environment === 'production') {
  ENV.baseURL = '/';
  ENV.locationType = 'hash';
  ENV.apiHost = '<% replace with the URL to your deployed API %>'
}
  1. Now you have to ensure you have your application/adapter and ajax files import the apiHost link.

In application/adapter file:

import ActiveModelAdapter from 'active-model-adapter';
import ENV from '<% ember-deployment-example name %>/config/environment';

export default ActiveModelAdapter.extend({
  host: ENV.apiHost,
  ...
  ...
  ...
});

IF/WHEN you have a ajax/service file:

import AjaxService from 'ember-ajax/services/ajax';
import ENV from '<% ember-deployment-example name %>/config/environment';

export default AjaxService.extend({
  host: ENV.apiHost,
  ...
  ...
  ...
});
  1. Make sure all work is committed and working on your master branch.
  2. Create a gh-pages branch locally via git checkout -b gh-pages.
  3. DO NOT PUSH TO GH-PAGES YET
  4. Remove /dist from .gitignore by adding a '#' before it.
  5. Add and commit this change.
  6. Run ember build --environment=production.
  7. git status and add all files changed (mainly dist/) and some other changes; Then commit all changes.
  8. Use "subtree push" to create a new gh-pages branch on GitHub composed only of the dist directory by using:
git subtree push --prefix dist origin gh-pages
  1. Go check to your github page site and ensure all requests are working and appear the same as on localhost:4200.
  2. Congrats, you've successfully deployed your Ember App!

Source code distributed under the MIT license. Text and other assets copyright General Assembly, Inc., all rights reserved.