All Projects → DockYard → ember-app-shell

DockYard / ember-app-shell

Licence: MIT license
No description or website provided.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ember-app-shell

Ember Cli Updater
ember-cli addon to help you update your ember-cli application or addon.
Stars: ✭ 32 (+39.13%)
Mutual labels:  ember-cli, ember, addon
Ember Web App
NOTICE: official repository moved to https://github.com/zonkyio/ember-web-app
Stars: ✭ 143 (+521.74%)
Mutual labels:  ember-cli, ember, addon
ember-window-messenger
This aims to be an simple window postMessage services provider.
Stars: ✭ 17 (-26.09%)
Mutual labels:  ember, addon
ember-osf
Ember Addon for interacting with the Open Science Framework
Stars: ✭ 14 (-39.13%)
Mutual labels:  ember, addon
ember-cli-geo
Geolocation service for Ember.js web apps
Stars: ✭ 48 (+108.7%)
Mutual labels:  ember-cli, ember
Ember Cli Mocha
Mocha and Chai tests for ember-cli applications
Stars: ✭ 147 (+539.13%)
Mutual labels:  ember-cli, ember
Ember Cli Notifications
⚛ Atom inspired notification messages for ember-cli
Stars: ✭ 168 (+630.43%)
Mutual labels:  ember-cli, ember
ember-vertical-timeline
A Vertical Timeline for Ember.js apps 🚀
Stars: ✭ 19 (-17.39%)
Mutual labels:  ember, addon
Ember Cli Eslint
Ember CLI addon for linting Ember projects with ESLint
Stars: ✭ 116 (+404.35%)
Mutual labels:  ember-cli, ember
ember-cli-qunit
QUnit testing package for ember-cli applications
Stars: ✭ 29 (+26.09%)
Mutual labels:  ember-cli, ember
ember-right-click-menu
An easy and flexible addon to add context menus anywhere in your application
Stars: ✭ 14 (-39.13%)
Mutual labels:  ember, addon
ember-cli-string-helpers
Set of the String helpers extracted from DockYard's ember-composable-helpers.
Stars: ✭ 73 (+217.39%)
Mutual labels:  ember-cli, ember
Ember Cli Pace
Pace.js load progress bar for Ember apps, incl. Flash-like initial script lazy loading
Stars: ✭ 128 (+456.52%)
Mutual labels:  ember-cli, ember
Intellij Emberjs
Ember.js support for JetBrains IDEs (IntelliJ, WebStorm, ...)
Stars: ✭ 202 (+778.26%)
Mutual labels:  ember-cli, ember
Ember Tether
Tether an element to another element in the DOM
Stars: ✭ 116 (+404.35%)
Mutual labels:  ember-cli, ember
ember-template-inspector
An ember add-on which opens the template file in the code editor while inspecting an element.
Stars: ✭ 15 (-34.78%)
Mutual labels:  ember-cli, ember
ember-cli-mentionable
An ember addon for facebook style @mentions and #hashtags
Stars: ✭ 13 (-43.48%)
Mutual labels:  ember-cli, addon
Ember Cli Bundle Analyzer
Analyze the size and contents of your Ember app's bundles
Stars: ✭ 78 (+239.13%)
Mutual labels:  ember-cli, ember
Ember Cli Stripe
Stripe checkout for Ember
Stars: ✭ 84 (+265.22%)
Mutual labels:  ember-cli, ember
ember-cli-nouislider
{{range-slider}} component for ember-cli powered by noUiSlider
Stars: ✭ 43 (+86.96%)
Mutual labels:  ember-cli, ember

ember-app-shell

ember-app-shell is built and maintained by DockYard, contact us for expert Ember.js consulting.

Renders an App Shell based on your actual running Ember.js application using Headless Chrome! It also inlines the relevant minimal CSS using the Critical tool.

How does this work?

Near the end of Ember CLI's build process, this addon loads your app in a Headless Chrome session and takes the rendered HTML and replaces index.html with the output of the /app-shell route. This way you are able to serve some static html before Ember boots up in the browser, but not having to maintain that manually in the index.html file.

See The App Shell Model on Google's Developer website for more information about what an App Shell is.

This addon is intended to be used with Ember Service Worker and the ember-service-worker-index addon.

Installation

ember install ember-app-shell

Make sure Google Chrome is installed on the build environment

You also need to make sure that every environment that will build your app runs Google Chrome (Canary). See the README of the chrome-launcher NPM package for more details on how to install Chrome on CI environments.

Export application global

To properly ensure app rendering of the app shell this addon makes use of Ember's visit API. To do this in all environments you must configure your app to export its application global for all environments. By default, Ember does not do this in production. Read more about exporting your application's global.

Getting Started

This addon will visit /app-shell by default when the Ember app is built by Ember CLI, so we need to make sure that route exists. The easiest way is to generate one using Ember CLI:

ember generate route app-shell

Now let's assume your application.hbs and app-shell.hbs look like the following:

{{! application.hbs}}
<header>
  <h1>My App's Name</h1>
  <img src="/assets/images/logo.png" alt="My App's Name Logo">
</header>

<main>
  {{outlet}}
</main>
{{! app-shell.hbs}}
<div class="page-loading-spinner">
  <img class="loading-spinner" src="/assets/images/loading-spinner.gif" alt="loading...">
</div>

Then after building (e.g. ember build) the built index.html file (e.g. dist/index.html) will contain:

<div id="ember377" class="ember-view">
  <header>
    <h1>My App's Name</h1>
    <img src="/assets/images/logo.png" alt="My App's Name Logo">
  </header>

  <main>
    <div id="ember422" class="ember-view">
      <div class="page-loading-spinner">
        <img class="loading-spinner" src="/assets/images/loading-spinner.gif" alt="loading...">
      </div>
    </div>
  </main>
</div>

If you now open up your app in the browser, you'll see the app shell content until the Ember.js app renders.

Configuration

There are multiple things you can configure, here's an example of how it can look like:

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    'ember-app-shell': {
      visitPath: '/my-app-shell',
      outputFile: 'my-app-shell.html',
      // https://peter.sh/experiments/chromium-command-line-switches/
      chromeFlags: [],
      // https://github.com/addyosmani/critical#options
      criticalCSSOptions: {
        width: 1300,
        height: 900
      },
      // enabled: false  (if you want to disable it. You can also pass `APP_SHELL_DISABLED=true` when running `ember serve`)
    }
  });

  return app.toTree();
};

visitPath

This determines which route in your application is used to render the app shell. If you have your router configured with locationType: 'hash' then you might need to set visitPath: '/#/app-shell'.

Default: /app-shell.

outputFile

This determines where the App Shell file is written to in your build. Specifying index.html will overwrite the existing index.html.

Default: index.html

chromeFlags

Flags passed to chrome by chrome-launcher.

Default: []

criticalCSSOptions

The options passed to the critical module.

Default: { minify: true }

Troubleshooting

ember server fails to start

If ember server results in a long idle time followed by an error similar to this, try enabling adding --no-sandbox to the chromeFlags option.

Error: connect ECONNREFUSED 127.0.0.1:44625
    at Object._errnoException (util.js:1021:11)
    at _exceptionWithHostPort (util.js:1043:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1175:14)

This may be needed on certain UNIX systems, which need this flag as a workaround to get chrome headless running (see GoogleChrome/chrome-launcher#6 and GoogleChrome/lighthouse#2726).

Legal

DockYard, Inc. © 2017

@dockyard

Licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].