-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
73 lines (56 loc) · 1.65 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';
const BroccoliDebug = require('broccoli-debug');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const fastbootTransform = require('fastboot-transform');
const path = require('path');
module.exports = {
name: 'ember-scrollmagic',
included(app) {
if (typeof app.import !== 'function' && app.app) {
app = app.app;
}
this.app = app;
this.addonConfig = this.app.project.config(app.env)['ember-scrollmagic'] || {};
const vendor = this.treePaths.vendor;
// Main modules
app.import(vendor + '/scrollmagic/ScrollMagic.js');
app.import(vendor + '/scrollmagic/plugins/animation.gsap.js');
// Add indicators
if (this.addonConfig.indicators) {
app.import(vendor + '/scrollmagic/plugins/debug.addIndicators.js');
}
// Expose `import` via a shim
app.import('vendor/shims/scrollmagic.js', {
exports: {
scrollmagic: ['default']
}
});
return this._super.included.apply(this, arguments);
},
treeForVendor(vendorTree) {
let debugTree = BroccoliDebug.buildDebugCallback(this.name),
trees = [];
if (vendorTree) {
trees.push(
debugTree(vendorTree, 'vendorTree')
);
}
let js = fastbootTransform(
moduleToFunnel('scrollmagic')
);
trees.push(
debugTree(js, 'js')
);
return mergeTrees(trees);
},
};
function moduleToFunnel(moduleName, destination) {
return new Funnel(resolveModulePath(moduleName), {
destDir: destination || moduleName
});
}
function resolveModulePath(moduleName) {
return path.dirname(require.resolve(moduleName));
}