forked from linstula/ember-cli-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (41 loc) · 2.03 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
var fs = require('fs');
var path = require('path');
module.exports = {
name: 'ember-cli-bootstrap',
included: function included(app) {
this.app = app;
var emberCLIVersion = app.project.emberCLIVersion();
if (emberCLIVersion < '0.0.41') {
throw new Error('ember-cli-bootstrap requires ember-cli version 0.0.41 or greater.\n');
}
var options = app.options['ember-cli-bootstrap'] || {};
var modulePath = path.relative(app.project.root, __dirname);
var bootstrapPath = 'vendor/bootstrap/dist/';
var emberBsPath = 'vendor/ember-addons.bs_for_ember/dist'
var javascriptsPath = path.join(emberBsPath, 'js');
var jsFiles = options.components ? options.components : fs.readdirSync(path.join(modulePath, javascriptsPath));
// Import css from bootstrap
if (options.importBootstrapTheme) {
app.import(path.join(bootstrapPath, 'css/bootstrap-theme.css'));
}
if (options.importBootstrapCSS !== false) {
app.import(path.join(bootstrapPath, 'css/bootstrap.css'));
}
app.import(path.join(bootstrapPath, 'css/bootstrap.css.map'), { destDir: 'assets' });
app.import(path.join(emberBsPath, 'css/bs-growl-notifications.min.css'));
// Import javascript files
app.import(path.join(javascriptsPath, 'bs-core.max.js')); // Import bs-core first
jsFiles.forEach(function(file) {
var fileName = file.split('.')[0];
app.import(path.join(javascriptsPath, fileName + '.max.js'));
});
if (options.importBootstrapJS) {
app.import(path.join(bootstrapPath, 'js/bootstrap.js'));
}
// Import glyphicons
app.import(path.join(bootstrapPath, 'fonts/glyphicons-halflings-regular.eot'), { destDir: '/fonts' });
app.import(path.join(bootstrapPath, 'fonts/glyphicons-halflings-regular.svg'), { destDir: '/fonts' });
app.import(path.join(bootstrapPath, 'fonts/glyphicons-halflings-regular.ttf'), { destDir: '/fonts' });
app.import(path.join(bootstrapPath, 'fonts/glyphicons-halflings-regular.woff'), { destDir: '/fonts' });
}
};