Skip to content

Commit

Permalink
version 0.1.0
Browse files Browse the repository at this point in the history
refactor service worker to try to get index.html from network first, then fall back to the cached version
  • Loading branch information
st-h committed May 19, 2019
1 parent 4f48da2 commit 748d41f
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 286 deletions.
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Ember Service Worker Index

**[ember-service-worker-index is built and maintained by DockYard, contact us for expert Ember.js consulting](https://dockyard.com/ember-consulting)**.

_An Ember Service Worker plugin that caches an Ember app's index file_

## F#$& my assets aren't updating in development mode
Expand All @@ -12,7 +10,7 @@ menu in the Chrome devtools.
## Installation

```
ember install ember-service-worker-index
ember install ember-service-worker-index-fallback
```

## Configuration
Expand All @@ -28,6 +26,9 @@ module.exports = function(defaults) {
// Where the location of your index file is at, defaults to `index.html`
location: 'app-shell.html',

// time in milliseconds that fetching index.html from network may take before the cached version is served
requestTimeout: 500,

// Bypass esw-index and don't serve cached index file for matching URLs
excludeScope: [/\/non-ember-app(\/.*)?$/, /\/another-app(\/.*)?$/],

Expand All @@ -50,21 +51,9 @@ module.exports = function(defaults) {
## Authors

* [Marten Schilstra](http://twitter.com/martndemus)
* [st-h](https://github.com/st-h)

## Versioning

This library follows [Semantic Versioning](http://semver.org)

## Want to help?

Please do! We are always looking to improve this library. Please see our
[Contribution Guidelines](https://github.com/dockyard/ember-service-worker-index/blob/master/CONTRIBUTING.md)
on how to properly submit issues and pull requests.

## Legal

[DockYard](http://dockyard.com/), Inc. © 2016

[@dockyard](http://twitter.com/dockyard)

[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var Config = require('./lib/config');
var mergeTrees = require('broccoli-merge-trees');

module.exports = {
name: 'ember-service-worker-index',
name: 'ember-service-worker-index-fallback',

included: function(app) {
this._super.included && this._super.included.apply(this, arguments);
Expand Down
2 changes: 2 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = class Config extends Plugin {
let location = options.location || "index.html";
let excludeScope = options.excludeScope || [];
let includeScope = options.includeScope || [];
let requestTimeout = options.requestTimeout || 500;

let fileLocation = location;
if (fileLocation[fileLocation.length - 1] === "/") {
Expand All @@ -42,6 +43,7 @@ module.exports = class Config extends Plugin {
module += `export const INDEX_HTML_PATH = '${location}';\n`;
module += `export const INDEX_EXCLUDE_SCOPE = [${excludeScope}];\n`;
module += `export const INDEX_INCLUDE_SCOPE = [${includeScope}];\n`;
module += `export const REQUEST_TIMEOUT = [${requestTimeout}];\n`;
module += `self.INDEX_FILE_HASH = '${hash}';\n`;

fs.writeFileSync(path.join(this.outputPath, "config.js"), module);
Expand Down
249 changes: 0 additions & 249 deletions package-lock.json

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "ember-service-worker-index",
"version": "0.7.0",
"name": "ember-service-worker-index-fallback",
"version": "0.8.0",
"description": "An Ember Service Worker plugin that caches the index.html file",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "https://github.com/DockYard/ember-service-worker-index",
"repository": "https://github.com/st-h/ember-service-worker-index-fallback",
"engines": {
"node": ">= 6.0.0"
},
Expand All @@ -18,7 +18,7 @@
],
"dependencies": {
"broccoli-merge-trees": "^3.0.1",
"broccoli-plugin": "^1.3.1"
"broccoli-plugin": "^2.1.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down
Loading

0 comments on commit 748d41f

Please sign in to comment.