forked from tomasbasham/ember-cli-pubnub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (49 loc) · 1.32 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
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
module.exports = {
name: require('./package').name,
/**
* Add the PubNub JavaScript package
* to the consuming application and
* expose the vendor shim enabling it
* to be imported as an es6 module.
*
* @method included
*
* @param {Object} app
* An EmberApp instance.
*/
included: function(app) {
this._super(app);
const vendorTree = this.treePaths.vendor;
// Import the PubNub package and shim.
app.import(`${vendorTree}/pubnub.js`);
app.import(`${vendorTree}/shims/pubnub.js`, {
exports: {
PubNub: ['default']
}
});
},
/**
* Resolve the path to the PubNub web
* bundle and transpose the files in
* that path into the project's vendor
* folder during build time.
*
* @method treeForVendor
*
* @params {Object} vendorTree
* The broccoli tree representing vendor files.
*/
treeForVendor: function(vendorTree) {
const pubnubPath = path.dirname(require.resolve('pubnub/dist/web/pubnub.js'));
const pubnubTree = new Funnel(pubnubPath, {
src: 'pubnub.js',
dest: './',
annotation: 'Funnel (PubNub)'
});
return mergeTrees([vendorTree, pubnubTree]);
}
};