-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
72 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
/* eslint-env node */
'use strict'
module.exports = {
name: 'ember-jquery',
included: function(app) {
this._super.included.apply(this, arguments)
// see: https://github.com/ember-cli/ember-cli/issues/3718
while (typeof app.import !== 'function' && app.app) {
app = app.app
}
this.app = app
this.jqueryOptions = this.getConfig()
var vendor = this.treePaths.vendor
app.import(vendor + '/shims/jquery.js', { prepend: true });
if (this.jqueryOptions.slim) {
app.import({
development: vendor + '/jquery/jquery.slim.js',
production: vendor + '/jquery/jquery.slim.min.js'
}, { prepend: true })
}
else {
app.import({
development: vendor + '/jquery/jquery.js',
production: vendor + '/jquery/jquery.min.js'
}, { prepend: true })
}
},
getConfig: function() {
var path = require('path')
var jqueryOptions = this.app.options.jquery || {}
var jqueryPath = path.dirname(require.resolve('jquery'))
var config = Object.assign({ slim: false }, jqueryOptions, {
path: jqueryPath
})
return config
},
treeForVendor: function(vendorTree) {
var Funnel = require('broccoli-funnel')
var mergeTrees = require('broccoli-merge-trees')
var map = require('broccoli-stew').map;
var trees = []
if (vendorTree) {
trees.push(vendorTree)
}
var jquery = new Funnel(this.jqueryOptions.path, {
destDir: 'jquery'
});
jquery = map(jquery, function(content) {
return 'if (typeof FastBoot === \'undefined\') {'
+ content +
'}';
});
trees.push(jquery)
return mergeTrees(trees)
}
}