1 |
|
2 | 'use strict';
|
3 |
|
4 | module.exports = {
|
5 | name: 'ember-cli-sri',
|
6 | included: function(app) {
|
7 | this._super.included.apply(this,arguments);
|
8 |
|
9 | this.options = app.options.SRI || {};
|
10 |
|
11 | if (!('enabled' in this.options)) {
|
12 | this.options.enabled = true;
|
13 | }
|
14 |
|
15 |
|
16 | this.options.runsIn = this.options.runsIn || ['production', 'test'];
|
17 |
|
18 |
|
19 | if (this.options.runsIn.indexOf(app.env) === -1) {
|
20 | this.options.enabled = false;
|
21 | }
|
22 |
|
23 | if ('fingerprint' in app.options && 'prepend' in app.options.fingerprint) {
|
24 | this.options.prefix = app.options.fingerprint.prepend;
|
25 | }
|
26 |
|
27 | if (app.options.origin) {
|
28 | this.options.origin = app.options.origin;
|
29 | }
|
30 |
|
31 | if (!('paranoiaCheck' in this.options)) {
|
32 | this.options.paranoiaCheck = false;
|
33 | }
|
34 |
|
35 | if (!('fingerprintCheck' in this.options)) {
|
36 | this.options.fingerprintCheck = false;
|
37 | }
|
38 | },
|
39 | postprocessTree: function(type, tree) {
|
40 | var options = this.options || {};
|
41 | if (type === 'all' && options.enabled) {
|
42 | return require('broccoli-sri-hash')(tree, options);
|
43 | } else {
|
44 | return tree;
|
45 | }
|
46 | }
|
47 | };
|