-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
73 lines (57 loc) · 1.71 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
/* eslint-env node */
'use strict';
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var VersionChecker = require('ember-cli-version-checker');
var path = require('path');
module.exports = {
name: 'ember-3d',
included(app) {
if (!isFastBoot()) {
this.importBrowserDependencies(app);
}
return this._super.included.apply(this, arguments);
},
importBrowserDependencies(app) {
if (arguments.length < 1) {
throw new Error('Application instance must be passed to import');
}
// `using: []` syntax isavailable for Ember 2.9.0 and above only
new VersionChecker(this).for('ember-cli', 'npm').assertAbove('2.9.0');
app.import(this.treePaths.vendor + '/three/three.js', {
using: [
{ transformation: 'amd', as: 'three' }
]
});
},
treeForVendor(vendorTree) {
if (isFastBoot()) {
return vendorTree;
} else {
return this.treeForBrowserVendor(vendorTree);
}
},
treeForBrowserVendor(vendorTree) {
var trees = [];
if (vendorTree) {
trees.push(vendorTree);
}
trees.push(moduleToFunnel('three'));
return mergeTrees(trees);
}
};
function moduleToFunnel(moduleName) {
return new Funnel(resolveModulePath(moduleName), {
destDir: 'three',
include: [new RegExp(/\.js$/)]
});
}
function resolveModulePath(moduleName) {
return path.dirname(require.resolve(moduleName));
}
// Checks to see whether this build is targeting FastBoot. Note that we cannot
// check this at boot time--the environment variable is only set once the build
// has started, which happens after this file is evaluated.
function isFastBoot() {
return process.env.EMBER_CLI_FASTBOOT === 'true';
}