-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
56 lines (45 loc) · 1.42 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
'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 root = this.project.root;
var hasRCFile = fs.existsSync(`${root}/.browserslistrc`);
var hasPkgBrowserList = !!this.project.pkg.browserslist;
var browserOptions = {};
if (!hasRCFile && !hasPkgBrowserList) {
var appOptions = this.app.options || {};
if (
appOptions['autoprefixer'] &&
appOptions['autoprefixer'].overrideBrowsersList
) {
browserOptions.overrideBrowsersList =
appOptions['autoprefixer'].overrideBrowsersList;
} else if (this.project.targets) {
browserOptions.overrideBrowsersList = this.project.targets.browsers;
}
}
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;
},
};