Coder Social home page Coder Social logo

oskarrough / ember-fastboot-now-deployment-example Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 4.0 222 KB

How to deploy an ember-cli app to Now. Also with Ember FastBoot.

Home Page: https://ember-now-deployment-example-hrwohadowc.now.sh/

JavaScript 68.21% HTML 31.79%
emberjs ember-fastboot

ember-fastboot-now-deployment-example's Introduction

Ember.js deployment to Now.sh

This example demonstrates how you can deploy an Ember + FastBoot application to now.

  1. Download now on https://zeit.co/download)
  2. Run now oskarrough/ember-now-deployment-example

That's it. Now, now will clone the repo, it will run either yarn or npm install (depending on your lock files) in the cloud followed by npm build and finally npm start and return a unique deployment URL.

How to deploy Ember to now with FastBoot

There are three steps.

  1. Install ember fastboot to your ember app
  2. Create a node.js server that serves your app
  3. Configure our scripts in package.json
  1. To get server-side rendering, we need to install two new packages:
yarn add ember-cli-fastboot fastboot-app-server

If you can run npm start and see your rendered app when you view source Note: your app might need some modifications before it can run in a non-browser environment. See https://ember-fastboot.com/.

  1. Create a new fastboot-server.js file in the root of your project. Copy/paste the following:
const FastBootAppServer = require('fastboot-app-server')
const server = new FastBootAppServer({
  distPath: 'dist',
  gzip: true // Optional - Enables gzip compression.
})
server.start()
  1. Now to configure the scripts. We will need to first run ember build and then start the new fastboot server.

When we run now it will run first npm build then npm start in the cloud. The normal start script for ember-cli runs ember serve. But through convention now allows you to overwrite what is run with now-build and `now-start. Like this:

"start-fastboot": "NODE_ENV=production node fastboot-server.js",
"now-start": "start-fastboot",

Example: https://ember-now-deployment-example-pqwagqtgcn.now.sh/ (check the source code, you'll see hello world in there)

Another note: now.sh servers "sleep" and currently waking up can take ~30 seconds. If you have a payed account, you can avoid this with now scale [insert-deployment-id] 1.

How to deploy Ember to now.sh without FastBoot

To deploy stuff on now, you need a package.json with start and build scripts defined. To use different commands locally and on now, use now-start and now-build.

Add the serve package, which now will use to serve the static website.

yarn add serve

Update engines in package.json to at least node version 6.9.0. This is a requirement from serve.

"engines": {
  "node": ">= 6.9.0"
}

Add two new scripts to your package.json.

"scripts": {
  "now-build": "ember build --environment=production",
  "now-start": "serve dist --single",
  ...

The --single flag to serve makes sure all requests are routed through your index.html.
Run now. Done.

Progressive Web App

To improve performance further, see the "PWA" branch on this repo and https://madhatted.com/2017/6/16/building-a-progressive-web-app-with-ember.

ember-fastboot-now-deployment-example's People

Contributors

ember-tomster avatar jakeleboeuf avatar oskarrough avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jakeleboeuf wlads

ember-fastboot-now-deployment-example's Issues

Deploy fails with bower dependencies

I'm not able to deploy, and getting the following error- you ever seen this?

Error: Couldn't find /home/nowuser/src/dist/package.json. You may need to update your version of ember-cli-fastboot.

My package.json contains:

  "dependencies": {
    "ember-cli-fastboot": "^1.0.0-beta.15",
    "fastboot-app-server": "^1.0.0-rc.5"
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.