-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathindex.js
More file actions
81 lines (69 loc) · 1.81 KB
/
index.js
File metadata and controls
81 lines (69 loc) · 1.81 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
'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;
if (!app.options['responsive-image']) {
app.options['responsive-image'] = {
images: [
{
include: 'images/**/*',
removeSource: false,
quality: 80,
widths: [2000, 1000, 600, 300],
},
],
};
}
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;
}