forked from emberjs/ember-jquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (35 loc) · 1.3 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
'use strict';
module.exports = {
name: require('./package').name,
included() {
this._super.included.apply(this, arguments);
let app = this._findHost();
let optionalFeatures = app.project.findAddonByName("@ember/optional-features");
if (!app.vendorFiles || !app.vendorFiles['jquery.js']) {
app.import('vendor/jquery/jquery.js', { prepend: true });
}
app.import('vendor/shims/jquery.js');
if (optionalFeatures && !optionalFeatures.isFeatureEnabled('jquery-integration')) {
app.project.ui.writeDeprecateLine('You have disabled the `jquery-integration` optional feature. You now have to delete `@ember/jquery` from your package.json');
}
},
treeForVendor: function(tree) {
const BroccoliMergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const resolve = require('resolve');
const path = require('path');
var jqueryPath;
try {
jqueryPath = path.dirname(
resolve.sync('jquery/package.json', { basedir: this.project.root })
);
} catch (error) {
jqueryPath = path.dirname(require.resolve('jquery/package.json'));
}
var jquery = new Funnel(jqueryPath + '/dist', {
destDir: 'jquery',
files: ['jquery.js'],
});
return new BroccoliMergeTrees([jquery, tree]);
},
};