forked from Shajansheriff/ember-cli-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (43 loc) · 1.41 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
'use strict';
const CssImport = require('postcss-import');
const PresetEnv = require('postcss-preset-env');
const BroccoliPostCSS = require('broccoli-postcss');
const mergeTrees = require('broccoli-merge-trees');
const funnel = require('broccoli-funnel');
const get = require('lodash.get');
const { join } = require('path');
const pkg = require('./package.json');
module.exports = {
name: require('./package').name,
treeForAddon() {
let tree = this._super(...arguments);
let app = this._findHost();
let options = typeof app.options === 'object' ? app.options : {};
let addonConfig = options[pkg.name] || {};
const addonWithoutStyles = funnel(tree, {
exclude: ['**/*.css'],
});
if (addonConfig.excludeCSS === true) {
return addonWithoutStyles;
}
const addonStyles = funnel(tree, {
include: ['**/*.css'],
});
// I don't know exactly why targets is private so I am using `get()` to make
// sure that it isn't missing
let overrideBrowserslist = get(this, 'app.project._targets.browsers');
let processedStyles = new BroccoliPostCSS(addonStyles, {
plugins: [
CssImport({
path: join(__dirname, 'addon', 'styles'),
}),
PresetEnv({
stage: 3,
features: { 'nesting-rules': true },
overrideBrowserslist,
}),
],
});
return mergeTrees([addonWithoutStyles, processedStyles]);
},
};