forked from Semantic-Org/Semantic-UI-Ember
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
95 lines (79 loc) · 2.87 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
/* eslint-env node */
'use strict';
var path = require('path');
var defaults = {
import: {
css: true,
javascript: true,
images: true,
fonts: true
},
source: {
css: 'bower_components/semantic-ui/dist',
javascript: 'bower_components/semantic-ui/dist',
images: 'bower_components/semantic-ui/dist/themes/default/assets/images',
fonts: 'bower_components/semantic-ui/dist/themes/default/assets/fonts'
},
destination: {
images: 'assets/themes/default/assets/images',
fonts: 'assets/themes/default/assets/fonts'
}
};
var getDefault = require('./lib/utils/get-default');
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var map = require('broccoli-stew').map;
module.exports = {
name: 'semantic-ui-ember',
included: function (app) {
var options = (app && app.project.config(app.env)['SemanticUI']) || {};
var importCss = getDefault('import', 'css', [options, defaults]);
if (importCss) {
var sourceCss = getDefault('source', 'css', [options, defaults]);
app.import({
development: path.join(sourceCss, 'semantic.css'),
production: path.join(sourceCss, 'semantic.min.css')
});
}
var importJavascript = getDefault('import', 'javascript', [options, defaults]);
if (importJavascript) {
this.sourceJavascript = getDefault('source', 'javascript', [options, defaults]);
app.import({
development: 'vendor/semantic.js',
production: 'vendor/semantic.min.js'
});
}
var importImages = getDefault('import', 'images', [options, defaults]);
if (importImages) {
var sourceImage = getDefault('source', 'images', [options, defaults]);
var imageOptions = { destDir: getDefault('destination', 'images', [options, defaults]) };
app.import(path.join(sourceImage, 'flags.png'), imageOptions);
}
var importFonts = getDefault('import', 'fonts', [options, defaults]);
if (importFonts) {
var fontExtensions = ['.eot','.otf','.svg','.ttf','.woff','.woff2'];
var sourceFont = getDefault('source', 'fonts', [options, defaults]);
var fontOptions = { destDir: getDefault('destination', 'fonts', [options, defaults]) };
for (var i = fontExtensions.length - 1; i >= 0; i--) {
app.import(path.join(sourceFont, 'icons' + fontExtensions[i]), fontOptions);
}
}
},
treeForVendor: function(vendorTree) {
var trees = [];
if (vendorTree) {
trees.push(vendorTree);
}
var sourceJavascript = this.sourceJavascript;
if (sourceJavascript) {
var semanticJsTree = new Funnel(sourceJavascript, {
srcDir: '/',
files: ['semantic.js', 'semantic.min.js']
});
semanticJsTree = map(semanticJsTree,
(content) => `if (typeof FastBoot === 'undefined') { ${content} }`);
trees.push(semanticJsTree);
}
return mergeTrees(trees);
}
};