-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
68 lines (58 loc) · 1.73 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
/* eslint-env node */
'use strict';
var Plugin = require('broccoli-plugin');
var MergeTrees = require('broccoli-merge-trees');
var CSSInjector = require('./lib/css_injector');
var path = require('path');
function CSSReader(inputNodes, options) {
options = options || {};
Plugin.call(this, inputNodes, {
annotation: options.annotation
});
this.options = options;
}
CSSReader.prototype = Object.create(Plugin.prototype);
CSSReader.prototype.constructor = CSSReader;
CSSReader.prototype.build = function() {
var injector = new CSSInjector({
rootPath: this.inputPaths[0],
filePathsToInject: this.options.filePathsToInject
});
injector.write(path.join(this.outputPath, 'index.html'));
};
module.exports = {
name: 'inline-css',
isDevelopingAddon() {
return false;
},
postprocessTree(type, tree) {
if (type === 'all') {
let filePathsToInject;
let filter = this.app.options['ember-inline-css'] && this.app.options['ember-inline-css'].filter
if (filter) {
filePathsToInject = filter;
} else {
// Need to detect path for glimmer vs Ember. In Glimmer
// `this.app.options.outputPaths.app.css` is a string
if (typeof this.app.options.outputPaths.app.css === 'string') {
filePathsToInject = [
this.app.options.outputPaths.app.css
];
} else {
filePathsToInject = [
this.app.options.outputPaths.app.css.vendor,
this.app.options.outputPaths.app.css.app
];
}
}
let cssReaderTree = new CSSReader([tree], {
filePathsToInject
});
return new MergeTrees([tree, cssReaderTree], {
overwrite: true
});
}
return tree;
},
CSSReader
};