-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
54 lines (44 loc) · 1.33 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
'use strict';
const DEFAULT_ASSET_VERSION = 'latest';
const getJSSource = ver => `https://cdn.reflect.io/${ver}/reflect.js`;
const getCSSSource = ver => `https://cdn.reflect.io/${ver}/reflect.css`;
const getHead = function(config) {
let cssSource = getCSSSource(DEFAULT_ASSET_VERSION);
let jsSource = getJSSource(DEFAULT_ASSET_VERSION);
let outputTag = '';
if (config.reflect) {
if (config.reflect.version) {
jsSource = getJSSource(config.reflect.version);
cssSource = getCSSSource(config.reflect.version);
}
if (config.reflect.js) {
jsSource = config.reflect.js;
}
if (config.reflect.css) {
cssSource = config.reflect.css;
}
}
let cssTag = `<link rel="stylesheet" href="${cssSource}">`;
let jsTag = `<script src="${jsSource}" type="text/javascript"></script>`;
if (config.reflect.excludeCss || config.reflect.excludeJs) {
if (config.reflect.excludeCss && !config.reflect.excludeJs) {
outputTag = jsTag;
} else if (!config.reflect.excludeCss && config.reflect.excludeJs) {
outputTag = cssTag;
}
} else {
outputTag = cssTag + jsTag;
}
return outputTag;
};
module.exports = {
name: 'ember-cli-reflect',
contentFor: function(type, config) {
if (type === 'head') {
return getHead(config);
}
},
isDevelopingAddon() {
return true;
},
};