This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
84 lines (65 loc) · 2.61 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
'use strict';
const Funnel = require('broccoli-funnel');
const {
buildFunnelConfig,
buildInclusionMap,
describeInclusionMap,
} = require('./component-tree.js');
/**
* @typedef {object} AddonConfig
*
* @property {string[]} [include]
* @property {boolean} [fontAwesome]
* @property {string} [fontDirectory]
*/
module.exports = {
name: require('./package').name,
prunedComponentFunnel: undefined,
fontDirectory: undefined,
included() {
this._super.included.apply(this, arguments);
const app = this._findHost();
const options = typeof app.options === 'object' ? app.options : {};
/** @type AddonConfig */
const addonConfig = options['ember-ui-foundation'] || {};
if (addonConfig.fontAwesome !== false) {
const destDir = (this.fontDirectory = addonConfig.fontDirectory || 'fonts');
this.import('node_modules/font-awesome/css/font-awesome.css');
this.import('node_modules/font-awesome/fonts/fontawesome-webfont.eot', { destDir });
this.import('node_modules/font-awesome/fonts/fontawesome-webfont.svg', { destDir });
this.import('node_modules/font-awesome/fonts/fontawesome-webfont.ttf', { destDir });
this.import('node_modules/font-awesome/fonts/fontawesome-webfont.woff', { destDir });
this.import('node_modules/font-awesome/fonts/fontawesome-webfont.woff2', { destDir });
}
if (Array.isArray(addonConfig.include) && addonConfig.include.length) {
const inclusionMap = buildInclusionMap(addonConfig.include);
this.prunedComponentFunnel = buildFunnelConfig(inclusionMap);
console.log(describeInclusionMap(addonConfig.include, inclusionMap));
}
},
contentFor(type, config) {
if (type === 'body-footer' && config.environment !== 'test') {
return '<div id="ui-positioning-root"></div>';
}
if (type === 'head-footer' && this.fontDirectory) {
const url = `${config.rootURL}${this.fontDirectory}/fontawesome-webfont`;
return `<link rel="preload" as="font" href="${url}.woff2?v=4.7.0" type="font/woff2" crossorigin="anonymous">`;
}
},
treeForAddon(addonTree) {
const funnelConfig = {
exclude: ['**/*.stories.*'],
};
if (this.prunedComponentFunnel) {
funnelConfig.exclude.push(this.prunedComponentFunnel.addon.exclude);
}
return this._super.treeForAddon.call(this, new Funnel(addonTree, funnelConfig));
},
treeForApp(appTree) {
const funnelConfig = { exclude: [] };
if (this.prunedComponentFunnel) {
funnelConfig.exclude.push(this.prunedComponentFunnel.app.exclude);
}
return this._super.treeForApp.call(this, new Funnel(appTree, funnelConfig));
},
};