forked from smashweaver/ember-cli-nprogress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (50 loc) · 1.59 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
/* jshint node: true */
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const MergeTrees = require('broccoli-merge-trees');
const debug = require('debug')('ember-cli-nprogress:addon');
const FastbootTransform = require('fastboot-transform');
/* identical to ember-cli/lib/models/addon.js's `_findHost` */
/* used instead of breaking backwards compat. w/ older versions of cli */
function findHost(addon) {
var current = addon;
var app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}
module.exports = {
name: 'ember-cli-nprogress',
included: function() {
this._super.included.apply(this, arguments);
debug('Importing NProgress files!');
var host = findHost(this);
host.import('vendor/nprogress/nprogress.js');
host.import('vendor/nprogress-shim.js', {
exports: {
nprogress: ['default']
}
});
host.import('vendor/nprogress/nprogress.css');
debug('Imported NProgress files!');
},
treeForVendor(vendorTree) {
const trees = [];
const nprogressJs = FastbootTransform(new Funnel(path.dirname(require.resolve('nprogress/nprogress.js')), {
files: ['nprogress.js'],
destDir: 'nprogress'
}));
const nprogressCss = new Funnel(path.dirname(require.resolve('nprogress/nprogress.js')), {
files: ['nprogress.css'],
destDir: 'nprogress'
})
if (vendorTree !== undefined) {
trees.push(vendorTree);
}
trees.push(nprogressJs);
trees.push(nprogressCss);
return new MergeTrees(trees);
}
};