forked from jonathanKingston/ember-cli-sri
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (38 loc) · 1.16 KB
/
index.js
File metadata and controls
47 lines (38 loc) · 1.16 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* jshint node: true */
'use strict';
module.exports = {
name: 'ember-cli-sri',
included: function(app) {
this._super.included.apply(this,arguments);
this.options = app.options.SRI || {};
if (!('enabled' in this.options)) {
this.options.enabled = true;
}
// SRI is default on
this.options.runsIn = this.options.runsIn || ['production', 'test'];
// Disable if application isn't in runs-in
if (this.options.runsIn.indexOf(app.env) === -1) {
this.options.enabled = false;
}
if ('fingerprint' in app.options && 'prepend' in app.options.fingerprint) {
this.options.prefix = app.options.fingerprint.prepend;
}
if (app.options.origin) {
this.options.origin = app.options.origin;
}
if (!('paranoiaCheck' in this.options)) {
this.options.paranoiaCheck = false;
}
if (!('fingerprintCheck' in this.options)) {
this.options.fingerprintCheck = false;
}
},
postprocessTree: function(type, tree) {
var options = this.options || {};
if (type === 'all' && options.enabled) {
return require('broccoli-sri-hash')(tree, options);
} else {
return tree;
}
}
};