forked from lifegadget/ember-cli-bootstrap-sassy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (54 loc) · 2.48 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
var path = require('path');
var funnel = require('broccoli-funnel');
module.exports = {
name: 'ember-cli-bootstrap-sassy',
included: function included(app) {
this.app = app;
var configMessage = [];
var o = app.options['ember-cli-bootstrap-sassy'] || { js: true, glyphicons: true };
var bootstrapPath = 'bower_components/bootstrap-sass/assets/';
var modulePath = path.relative(app.project.root, __dirname);
var path_join = function(){
// fix path with windows back slash with path_join
return path.join.apply(this, arguments).replace(/\\/g, '/');
};
var emberCLIVersion = app.project.emberCLIVersion().split(',').map(function(item) {return Number(item);});
if (emberCLIVersion[1] === 0 || emberCLIVersion[2] < 8) {
throw new Error('ember-cli-bootstrap-sassy requires ember-cli version 0.1.8 or greater.\n');
}
// Import JS from bootstrap
if(o.js instanceof Array) {
o.js.forEach(function(fileName) {
app.import(bootstrapPath + 'javascripts/bootstrap/' + fileName + '.js');
});
configMessage.push('some JS loaded [' + o.js.join(',') + ']');
} else if (o.js !== false) {
app.import(bootstrapPath + 'javascripts/bootstrap.js');
configMessage.push('all JS enabled');
} else {
configMessage.push('no JS enabled');
}
// Import glyphicons from bootstrap
if(o.glyphicons !== false) {
app.import(bootstrapPath + 'fonts/bootstrap/glyphicons-halflings-regular.eot', { destDir: '/fonts/bootstrap' });
app.import(bootstrapPath + 'fonts/bootstrap/glyphicons-halflings-regular.svg', { destDir: '/fonts/bootstrap' });
app.import(bootstrapPath + 'fonts/bootstrap/glyphicons-halflings-regular.ttf', { destDir: '/fonts/bootstrap' });
app.import(bootstrapPath + 'fonts/bootstrap/glyphicons-halflings-regular.woff', { destDir: '/fonts/bootstrap' });
app.import(bootstrapPath + 'fonts/bootstrap/glyphicons-halflings-regular.woff2', { destDir: '/fonts/bootstrap' });
configMessage.push('glyphicons enabled');
} else {
configMessage.push('glyphicons disabled');
}
if(o.quiet !== true) {
console.log('bootstrap-sassy config: ', configMessage.join(', '));
}
},
treeForStyles: function(){
var bootstrapPath = path.join(this.app.bowerDirectory, 'bootstrap-sass', 'assets/stylesheets');
var bootstrapTree = new funnel(bootstrapPath, {
srcDir: '/',
destDir: '/app/styles'
});
return bootstrapTree;
}
};