-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.js
62 lines (51 loc) · 1.5 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
/* eslint-disable prettier/prettier */
'use strict';
const autoprefixer = require('autoprefixer');
const colorFunction = require('postcss-color-function');
const cssnano = require('cssnano');
const customProperties = require('postcss-custom-properties');
const easyImport = require('postcss-easy-import');
const postcssOptions = {
compile: {
enable: true,
plugins: [
{ module: easyImport },
{ module: customProperties, options: { preserve: false } },
{ module: colorFunction },
{ module: autoprefixer, options: { overrideBrowserslist: ['last 2 versions'] } },
{ module: cssnano },
]
}
};
module.exports = {
name: require('./package').name,
options: {
postcssOptions,
'responsive-image': {
images: [{
include: 'images/**/*',
removeSource: false,
quality: 80,
widths: [2000, 1000, 600, 300],
}]
}
},
included() {
let app = findHost(this);
app.options.postcssOptions = postcssOptions;
this._super.included.apply(this, arguments);
},
contentFor() {
let responsiveImage = this.addons.find((a) => a.name === 'ember-responsive-image');
return responsiveImage.contentFor(...arguments);
},
};
// Polyfill [Addon._findHost](https://ember-cli.com/api/classes/Addon.html#method__findHost) for older versions of ember-cli
function findHost(addon) {
var current = addon;
var app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}