-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
97 lines (80 loc) · 2.34 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* eslint-disable */
'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-stereo',
options: {
svgJar: {
sourceDirs: ['public', 'tests/dummy/public/assets/images/'],
},
babel: {
plugins: [require.resolve('ember-auto-import/babel-plugin')],
},
},
included(app, parentAddon) {
this._super.included.apply(this, arguments);
var target = parentAddon || app;
while (target.app && !target.bowerDirectory) {
target = target.app;
}
this.getStereoConnections();
if (this.stereoConnections.includes('Howler')) {
target.import({
development: 'vendor/third-party/howler.js',
production: 'vendor/third-party/howler.min.js',
});
target.import('vendor/howler.js');
}
if (this.stereoConnections.includes('HLS')) {
target.import({
development: 'vendor/third-party/hls.light.js',
production: 'vendor/third-party/hls.light.min.js',
});
target.import('vendor/hls.js');
}
},
treeForVendor(vendorTree) {
var trees = [];
this.getStereoConnections();
if (vendorTree) {
trees.push(vendorTree);
}
if (this.stereoConnections.includes('Howler')) {
trees.push(
new Funnel(path.dirname(require.resolve('howler')), {
files: ['howler.js', 'howler.min.js'],
destDir: 'third-party',
})
);
}
if (this.stereoConnections.includes('HLS')) {
trees.push(
new Funnel(path.dirname(require.resolve('hls.js')), {
files: ['hls.light.js', 'hls.light.min.js', 'hls.light.js.map'],
destDir: 'third-party',
})
);
}
return mergeTrees(trees);
},
getStereoConnections: function () {
if (this.stereoConnections) {
return;
}
let projectConfig = this.project.config(process.env.EMBER_ENV);
let stereoConfig = projectConfig.emberStereo;
if (stereoConfig && stereoConfig.connections) {
this.stereoConnections = stereoConfig.connections.map(
(connection) => connection.name
);
} else {
// Default
this.stereoConnections = ['NativeAudio', 'HLS', 'Howler'];
}
},
isDevelopingAddon: function () {
return true;
},
};