This repository was archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (42 loc) · 1.28 KB
/
index.js
File metadata and controls
57 lines (42 loc) · 1.28 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
48
49
50
51
52
53
54
55
56
57
'use strict';
const WebpackWriter = require('broccoli-webpack');
const mergeTrees = require('broccoli-merge-trees');
const path = require('path');
module.exports = {
name: require('./package').name,
defaultOptions: {
important: true
},
included() {
const target = this._findHost();
this.addonOptions = Object.assign({}, this.defaultOptions, target.options && target.options[this.name]);
this._super.included.apply(this, arguments);
target.import('vendor/aphrodite.amd.js');
},
treeForVendor(tree) {
const aphroditePath = path.dirname(require.resolve('aphrodite'));
const aphroditeTree = new WebpackWriter([aphroditePath], {
entry: this.addonOptions.important ? './index.js' : './no-important.js',
output: {
filename: 'aphrodite.amd.js',
library: 'aphrodite',
libraryTarget: 'amd'
}
});
if (!tree) {
return this._super.treeForVendor.call(this, aphroditeTree);
}
const trees = mergeTrees([aphroditeTree, tree], {
overwrite: true
});
return this._super.treeForVendor.call(this, trees);
},
_findHost: function() {
let current = this;
let app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}
};