forked from Ember-Swiper/ember-cli-swiper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (32 loc) · 1.21 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
'use strict';
const map = require('broccoli-stew').map; // eslint-disable-line ember-suave/prefer-destructuring, node/no-extraneous-require
const path = require('path');
const Funnel = require('broccoli-funnel'); // eslint-disable-line node/no-extraneous-require
const MergeTrees = require('broccoli-merge-trees'); // eslint-disable-line node/no-extraneous-require
module.exports = {
name: 'ember-cli-swiper',
treeForVendor(defaultTree) {
let trees = [];
let swiperPath = path.join(path.dirname(require.resolve('swiper')), '..');
let browserVendorLib = new Funnel(swiperPath, {
destDir: 'swiper',
include: ['js/swiper.js', 'css/swiper.css']
});
browserVendorLib = map(browserVendorLib, (content, relativePath) => {
if (relativePath.indexOf('css') !== -1) {
return content;
}
return `if (typeof FastBoot === 'undefined') { ${content} }`;
});
if (defaultTree !== undefined) {
trees.push(defaultTree);
}
trees.push(browserVendorLib);
return new MergeTrees(trees);
},
included(/* app */) {
this._super.included.apply(this, arguments);
this.import('vendor/swiper/js/swiper.js');
this.import('vendor/swiper/css/swiper.css');
}
};