-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
80 lines (63 loc) · 1.83 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
'use strict';
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const denaliCssPath = require('denali-css').getFilePath();
const denaliIconPath = require('denali-icon-font').getFilePath();
const iconFiles = ['css', 'eot', 'svg', 'ttf', 'woff'];
module.exports = {
name: require('./package').name,
options: {
'ember-composable-helpers': {
only: ['includes'],
},
},
treeForVendor(tree) {
const trees = tree ? [tree] : [];
if (!this.hasSass) {
const denali = new Funnel(denaliCssPath, {
srcDir: 'css',
files: ['denali.css'],
});
trees.push(denali);
}
if (this.includeIcons) {
const icons = new Funnel(denaliIconPath, {
srcDir: 'dist',
files: iconFiles.map((ext) => `denali-icon-font.${ext}`),
});
trees.push(icons);
}
return mergeTrees(trees);
},
treeForStyles(tree) {
const trees = tree ? [tree] : [];
if (this.hasSass) {
const denali = new Funnel(denaliCssPath, {
srcDir: 'scss',
destDir: 'denali',
});
trees.push(denali);
}
return mergeTrees(trees);
},
included(app) {
this._super.included.apply(this, arguments);
const options = typeof app.options === 'object' ? app.options : {};
const addonConfig = options['@denali-design/ember'] || {};
this.includeIcons = addonConfig.includeIcons !== false;
this.hasSass =
!!app.registry.availablePlugins['ember-cli-sass'] || !!app.registry.availablePlugins['ember-cli-sass-less'];
// CSS Files
if (!this.hasSass) {
app.import('vendor/denali.css');
}
// Icon Files
if (this.includeIcons) {
iconFiles.forEach((ext) => {
app.import(`vendor/denali-icon-font.${ext}`, {
destDir: 'assets',
});
});
}
},
};