-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
76 lines (58 loc) · 1.79 KB
/
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
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
var path = require('path');
var Funnel = require('broccoli-funnel'); //eslint-disable-line
var mergeTrees = require('broccoli-merge-trees'); //eslint-disable-line
module.exports = {
name: 'ember-hifi',
included(app, parentAddon) {
this._super.included.apply(this, arguments);
var target = parentAddon || app;
while (target.app && !target.bowerDirectory) {
target = target.app;
}
this.getHifiConnections();
if (this.hifiConnections.includes('Howler')) {
target.import({
development: 'vendor/third-party/howler.js',
production: 'vendor/third-party/howler.min.js'
});
target.import('vendor/howler.js');
}
if (this.hifiConnections.includes('HLS')) {
target.import({
development: 'vendor/third-party/hls.js',
production: 'vendor/third-party/hls.min.js'
});
target.import('vendor/hls.js');
}
},
treeForVendor(vendorTree) {
var trees = [];
this.getHifiConnections();
if (vendorTree) {
trees.push(vendorTree);
}
if (this.hifiConnections.includes('Howler')) {
trees.push(new Funnel(path.dirname(require.resolve('howler')), {
files: ['howler.js', 'howler.min.js'],
destDir: 'third-party'
}));
}
if (this.hifiConnections.includes('HLS')) {
trees.push(new Funnel(path.dirname(require.resolve('hls.js')), {
files: ['hls.js', 'hls.min.js', 'hls.js.map'],
destDir: 'third-party'
}));
}
return mergeTrees(trees);
},
getHifiConnections: function() {
if (this.hifiConnections) {
return;
}
this.hifiConnections = this.project.config(process.env.EMBER_ENV).emberHifi.connections.map((connection) => connection.name);
},
isDevelopingAddon: function() {
return true;
}
};