forked from FirebaseExtended/emberfire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (43 loc) · 1.09 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
/* jshint node: true */
'use strict';
var path = require('path');
var Webpack = require('broccoli-webpack');
var mergeTrees = require('broccoli-merge-trees');
module.exports = {
name: 'emberfire',
included: function included(app) {
this._super.included(app);
// make sure app is correctly assigned when being used as a nested addon
if (app.app) {
app = app.app;
}
this.app = app;
this.app.import('vendor/firebase.amd.js');
},
treeForVendor: function(tree) {
var trees = [];
var firebase;
try {
var resolve = require('resolve');
firebase = resolve.sync('firebase/package.json', {
basedir: this.project.root
});
} catch (e) {
firebase = require.resolve('firebase/package.json');
}
trees.push(new Webpack([
path.dirname(firebase)
], {
entry: './firebase-browser.js',
output: {
library: 'firebase',
libraryTarget: 'amd',
filename: 'firebase.amd.js'
}
}));
if (tree) {
trees.push(tree);
}
return mergeTrees(trees, { overwrite: true });
}
};