This repository has been archived by the owner on Nov 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
77 lines (63 loc) · 2.02 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
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const map = require('broccoli-stew').map;
module.exports = {
name: 'ember-medium-editor',
included(app) {
if (typeof app.import !== 'function' && app.app) {
app = app.app;
}
this.app = app;
this.addonConfig = this.getConfig();
// Setup paths
let vendorPath = this.treePaths.vendor;
let jsPath = path.join(vendorPath, 'medium-editor', 'js');
let stylesPath = path.join(vendorPath, 'medium-editor', 'css');
// Import js
this.import({
development: path.join(jsPath, 'medium-editor.js'),
production: path.join(jsPath, 'medium-editor.min.js')
});
this.import(path.join(vendorPath, 'shims', 'medium-editor.js'));
// Import styles
if (!this.addonConfig.excludeStyles) {
let theme = this.addonConfig.theme;
this.import({
development: path.join(stylesPath, 'medium-editor.css'),
production: path.join(stylesPath, 'medium-editor.min.css')
});
this.import({
development: path.join(stylesPath, 'themes', `${theme}.css`),
production: path.join(stylesPath, 'themes', `${theme}.min.css`)
});
}
return this._super.included.apply(this, arguments);
},
treeForVendor(vendorTree) {
let moduleName = 'medium-editor';
let modulePath = path.join(require.resolve(moduleName), '..', '..');
let jsTree = new Funnel(modulePath, {
include: ['js/**/*'],
destDir: moduleName
});
jsTree = map(jsTree, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);
let cssTree = new Funnel(modulePath, {
include: ['css/**/*'],
destDir: moduleName
});
return mergeTrees([vendorTree, jsTree, cssTree]);
},
getConfig() {
return Object.assign({
excludeStyles: false,
theme: 'default'
}, this.app.options.mediumEditor);
},
options: {
babel: {
plugins: ['transform-object-rest-spread']
}
}
};