/
index.js
51 lines (38 loc) · 1.24 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
'use strict';
const Autoprefixer = require('broccoli-autoprefixer');
const fs = require('fs');
const treesToProcess = ['css', 'less', 'styl', 'scss', 'sass'];
module.exports = {
name: require('./package').name,
included: function(app) {
this.app = app;
if (typeof app.import !== 'function' && app.app) {
this.app = app = app.app;
}
this._super.included.apply(this, arguments);
var browserOptions = {};
var root = this.project.root;
var hasRCFile = !!fs.existsSync(`${root}/.browserlistrc`);
var hasPkgBrowserList = !!require('./package').browserslist;
if (!hasRCFile && !hasPkgBrowserList) {
var addonOptions = this.app.options || {};
var config = addonOptions[this.name] || {};
browserOptions.overrideBrowsersList = config['autoprefixer'] && config['autoprefixer'].overrideBrowsersList;
}
this.options = Object.assign(
{
enabled: true
},
browserOptions,
this.app.options.autoprefixer || {}
);
this.enabled = this.options.enabled;
delete this.options.enabled;
},
postprocessTree: function(type, tree) {
if (this.enabled && treesToProcess.includes(type)) {
tree = new Autoprefixer(tree, this.options);
}
return tree;
}
};