forked from DockYard/ember-service-worker-asset-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (23 loc) · 939 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* jshint node: true */
'use strict';
var AssetMap = require('./lib/asset-map');
var mergeTrees = require('broccoli-merge-trees');
module.exports = {
name: 'ember-service-worker-asset-cache',
included: function(app) {
this._super.included && this._super.included.apply(this, arguments);
this.app = app;
this.app.options = this.app.options || {};
this.app.options['asset-cache'] = this.app.options['asset-cache'] || {};
this.app.options['asset-cache'].appName =
this.app.name || this.app.options['asset-cache'].appName;
if (this.app.options.fingerprint && this.app.options.fingerprint.enabled) {
this.app.options['asset-cache'].prepend = this.app.options.fingerprint.prepend;
}
},
treeForServiceWorker(swTree, appTree) {
var options = this.app.options['asset-cache'];
var assetMapFile = new AssetMap([appTree], options);
return mergeTrees([swTree, assetMapFile]);
}
};