Use this guide to deploy Ember apps based on our Ember Template to GitHub Pages.
By the end of this, developers should be able to:
- Deploy an Ember app to GitHub Pages
- If you haven't already, run
npm install
andbower install
. - Make sure that everything is named consistently (i.e.
ember-template
-><% NAME OF YOUR CLIENT %>
). (Search viacommand+shift+f
) - 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 %>'
}
- Now you have to ensure you have your
application/adapter
andajax
files import theapiHost
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,
...
...
...
});
- Make sure all work is committed and working on your
master
branch. - Create a
gh-pages
branch locally viagit checkout -b gh-pages
. - DO NOT PUSH TO GH-PAGES YET
- Remove
/dist
from.gitignore
by adding a '#' before it. - Add and commit this change.
- Run
ember build --environment=production
. git status
and add all files changed (mainlydist/
) and some other changes; Thencommit
all changes.- 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
- Go check to your github page site and ensure all requests are working and appear the same as on localhost:4200.
- 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.