-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
112 lines (99 loc) · 3.85 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
'use strict';
const { buildEngine } = require('ember-engines/lib/engine-addon');
const { name } = require('./package');
const Funnel = require('broccoli-funnel');
const MergeTrees = require('broccoli-merge-trees');
const resolve = require('resolve');
const path = require('path');
module.exports = buildEngine({
name,
postprocessTree(type, tree) {
if (type === 'css') {
tree = new Funnel(tree, {
exclude: ['**/@fleetbase/ember-ui/**/*.css'],
});
}
return tree;
},
lazyLoading: {
enabled: true,
},
treeForPublic: function () {
const publicTree = this._super.treeForPublic.apply(this, arguments);
const leafletPath = path.dirname(require.resolve('leaflet'));
const leafletImagesPath = path.join(leafletPath, 'images');
const alwaysExclude = ['LICENSE', 'package.json', 'example.html'];
const leafletAddons = [
{ package: 'leaflet', include: ['leaflet-src.js'], exclude: [...alwaysExclude], path: ['dist'] },
{ package: 'leaflet-contextmenu', include: undefined, exclude: [...alwaysExclude], path: ['dist'] },
{ package: 'leaflet-draw', include: undefined, exclude: [...alwaysExclude], path: ['dist'] },
{ package: 'leaflet-rotatedmarker', include: undefined, exclude: [...alwaysExclude], path: [] },
{
package: 'leaflet-drift-marker',
include: ['index.js', 'index.js.map'],
exclude: [...alwaysExclude],
path: ['lib'],
getDestinationPath: (relativePath) => {
if (relativePath === 'index.js') {
return 'leaflet-drift-marker.js';
}
if (relativePath === 'index.js.map') {
return 'leaflet-drift-marker.js.map';
}
return relativePath;
},
},
];
const trees = [];
for (let i = 0; i < leafletAddons.length; i++) {
const leafletAdddon = leafletAddons[i];
const leafletAddonDist = path.join(this.pathBase(leafletAdddon.package), ...leafletAdddon.path);
trees.push(
new Funnel(leafletAddonDist, {
destDir: 'leaflet',
include: leafletAdddon.include,
exclude: leafletAdddon.exclude,
getDestinationPath: leafletAdddon.getDestinationPath,
})
);
}
// jointjs
const jointJsPath = path.join(this.pathBase('@joint/core'), 'dist');
trees.push(
new Funnel(jointJsPath, {
destDir: '/',
include: ['joint.min.js'],
exclude: [],
})
);
// jointjs directed graph
const jointJsDirectedGraphPath = path.join(this.pathBase('@joint/layout-directed-graph'), 'dist');
trees.push(
new Funnel(jointJsDirectedGraphPath, {
destDir: '/',
include: ['DirectedGraph.min.js'],
exclude: [],
})
);
trees.push(
new Funnel(leafletImagesPath, {
srcDir: '/',
destDir: '/leaflet-images',
allowEmpty: true,
})
);
trees.push(
new Funnel(path.join(__dirname, 'assets'), {
destDir: '/',
})
);
// Merge the addon tree with the existing tree
return publicTree ? new MergeTrees([publicTree, ...trees], { overwrite: true }) : new MergeTrees([...trees], { overwrite: true });
},
pathBase(packageName) {
return path.dirname(resolve.sync(packageName + '/package.json', { basedir: __dirname }));
},
isDevelopingAddon() {
return true;
},
});