Edgio

Ember.js

This guide shows you how to deploy an Ember.js application to Edgio.

Example

Prerequisites

Setup requires:

Install the Edgio CLI

If you have not already done so, install the Edgio CLI.
Bash
1npm i -g @layer0/cli@latest

Create a new Ember.js app

If you don’t already have an Ember.js app, create one by running the following:
Bash
1npm install -g ember-cli
2ember new ember-quickstart --lang en
3cd ember-quickstart
You can verify your app works by running it locally with:
Bash
1ember serve

Configuring your Ember.js app for Edgio

Initialize your project

In the root directory of your project run 0 init:
Bash
10 init
This will automatically update your package.json and add all of the required Edgio dependencies and files to your project. These include:
  • The @layer0/core package - Allows you to declare routes and deploy your application on Edgio
  • The @layer0/prefetch package - Allows you to configure a service worker to prefetch and cache pages to improve browsing speed
  • layer0.config.js - A configuration file for Edgio
  • routes.js - A default routes file that sends all requests to Ember.js.

Configure the routes

Update routes.js at the root of your project to the following:
JavaScript
1// This file was added by layer0 init.
2// You should commit this file to source control.
3
4import { Router } from '@layer0/core/router'
5
6export default new Router()
7 // Prevent search engine bot(s) from indexing
8 // Read more on: https://docs.layer0.co/applications/cookbook#blocking-search-engine-crawlers
9 .noIndexPermalink()
10 .match('/robots.txt', ({ serveStatic }) => {
11 serveStatic('dist/robots.txt')
12 })
13 .match('/assets/:path*', ({ cache, serveStatic }) => {
14 cache({
15 edge: {
16 maxAgeSeconds: 60 * 60 * 60 * 365,
17 forcePrivateCaching: true,
18 },
19 browser: {
20 maxAgeSeconds: 0,
21 serviceWorkerSeconds: 60 * 60 * 24,
22 },
23 })
24 serveStatic('dist/assets/:path*')
25 })
26 .fallback(({ appShell }) => {
27 appShell('dist/index.html')
28 })
Refer to the Routing guide for the full syntax of the routes.js file and how to configure it for your use case.

Run the Ember.js app locally on the Sites

Create a production build of your app by running the following in your project’s root directory:
Bash
1npm run build
Test your app with the Sites on your local machine by running the following command in your project’s root directory:
Bash
10 dev
Load the site http://127.0.0.1:3000

Deploying

Create a production build of your app by running the following in your project’s root directory:
Bash
1npm run build
Deploy your app to the Sites by running the following command in your project’s root directory:
Bash
10 deploy
Refer to the Deploying guide for more information on the deploy command and its options.