forked from kturney/ember-mapbox-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (54 loc) · 1.73 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
'use strict';
module.exports = {
name: require('./package').name,
options: {
babel: {
plugins: [
// Ensure that `ember-auto-import` can handle the dynamic imports
require('ember-auto-import/babel-plugin')
]
}
},
addonJsFiles() {
const Funnel = require('broccoli-funnel');
const config = this._findHost().options[this.name];
const tree = this._super.addonJsFiles.apply(this, arguments);
if (config && config.lazyLoad === true) {
return new Funnel(tree, {
exclude: [ 'ember-mapbox-gl/-private/mapbox-loader-static.js' ],
getDestinationPath(relativePath) {
if (relativePath === 'ember-mapbox-gl/-private/mapbox-loader-dynamic.js') {
return 'ember-mapbox-gl/-private/mapbox-loader.js';
}
return relativePath;
}
});
}
return new Funnel(tree, {
exclude: [ 'ember-mapbox-gl/-private/mapbox-loader-dynamic.js' ],
getDestinationPath(relativePath) {
if (relativePath === 'ember-mapbox-gl/-private/mapbox-loader-static.js') {
return 'ember-mapbox-gl/-private/mapbox-loader.js';
}
return relativePath;
}
});
},
treeForStyles(tree) {
const Funnel = require('broccoli-funnel');
const mapboxDirName = require('path').dirname(require.resolve('mapbox-gl'));
const mapboxGlTree = new Funnel(mapboxDirName, {
files: [ 'mapbox-gl.css' ],
destDir: 'app/styles'
});
if (tree) {
const MergeTrees = require('broccoli-merge-trees');
return new MergeTrees([ tree, mapboxGlTree ]);
}
return mapboxGlTree;
},
included(app) {
this._super.included.apply(this, arguments);
app.import('app/styles/mapbox-gl.css');
}
};