forked from projectcaluma/ember-caluma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (45 loc) · 1.44 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
"use strict";
const path = require("path");
const Funnel = require("broccoli-funnel");
const mergeTrees = require("broccoli-merge-trees");
// eslint-disable-next-line node/no-unpublished-require
const EngineAddon = require("ember-engines/lib/engine-addon");
const DEFAULT_OPTIONS = {
includeMirageConfig: true,
includeProxyPolyfill: true,
};
/* eslint-disable ember/avoid-leaking-state-in-ember-objects */
module.exports = EngineAddon.extend({
name: require("./package.json").name,
lazyLoading: false,
// see https://github.com/dfreeman/ember-cli-node-assets/issues/11
// for why this is not wrapped in `options`
babel: {
plugins: ["@babel/plugin-proposal-object-rest-spread"],
},
_getOptions() {
const app = this._findHost();
return Object.assign({}, DEFAULT_OPTIONS, app.options["ember-caluma"]);
},
included(...args) {
this._super.included.apply(this, args);
if (this._getOptions().includeProxyPolyfill) {
this.import("node_modules/proxy-polyfill/proxy.min.js");
}
},
treeForApp(appTree) {
const trees = [appTree];
const app = this._findHost();
if (
this._getOptions().includeMirageConfig &&
app.registry.availablePlugins["ember-cli-mirage"]
) {
const mirageDir = path.join(__dirname, "addon-mirage-support");
const mirageTree = new Funnel(mirageDir, {
destDir: "mirage",
});
trees.push(mirageTree);
}
return mergeTrees(trees);
},
});