-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclark-plugin.js
More file actions
122 lines (100 loc) · 4.19 KB
/
clark-plugin.js
File metadata and controls
122 lines (100 loc) · 4.19 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const Plugin = require('ember-css-modules/lib/plugin');
module.exports = class ClarkPlugin extends Plugin {
get project() {
let project = this.parent;
while (project.parent) {
project = project.parent;
}
return project;
}
get browsers() {
return (this.project.targets && this.project.targets.browsers) || null;
}
config(environment, baseConfig) {
const before = [
// https://github.com/postcss/postcss-mixins
// Use @define-mixin and @mixin rules
// require('postcss-mixins'),
// Deactivated, see https://github.com/postcss/postcss-mixins/issues/104
// https://github.com/jonathantneal/postcss-pseudo-class-enter
// Use :enter, which is equal to :hover and :focus combined
require('postcss-pseudo-class-enter'),
// https://github.com/postcss/postcss-custom-selectorsx
// @custom-selector :--heading h1, h2, h3;
require('postcss-custom-selectors'),
// https://github.com/jedmao/postcss-nested-props
// Nest properties like `font: { size: 10px; family: Helvetica; }`
// @TODO: https://github.com/jedmao/postcss-nested-props/issues/9
// require('postcss-nested-props'),
// https://github.com/toomuchdesign/postcss-nested-ancestors
// Reference an ancestor in nested rules with ^&
require('postcss-nested-ancestors'),
// https://github.com/postcss/postcss-nested
// Nest rules and reference the parent via &
require('postcss-nested'),
// https://github.com/jonathantneal/postcss-advanced-variables
// @if, @else and @else if
// Iterate over numeric ranges with @for
// Iterate over lists with @each
require('postcss-advanced-variables')({
disable: '@mixin, @include, @content',
unresolved: 'ignore'
}),
// https://github.com/jonathantneal/postcss-short
// Shorthand properties
require('postcss-short')
// https://github.com/simonsmith/postcss-property-lookup
// Lookup property values of the current rule set, e.g. padding-top: @margin-bottom
// @TODO: https://github.com/simonsmith/postcss-property-lookup/pull/27#issuecomment-438264254
// require('postcss-property-lookup')
];
const after = [
// https://github.com/postcss/postcss-calc
// Reduce `calc()` expressions whenever possible
require('postcss-calc'),
// https://github.com/postcss/postcss-color-function
// Transform W3C CSS color function to more compatible CSS
require('postcss-color-function'),
// https://github.com/seaneking/postcss-hexrgba
// Adds shorthand hex methods to rbga() values.
require('postcss-hexrgba'),
// https://github.com/larsenwork/postcss-easing-gradients
// cubic-bezier() for linear-gradient()
require('postcss-easing-gradients'),
// https://github.com/csstools/postcss-preset-env
// Adds vendor prefixes based on Can I Use and polyfills new features
// Inspired by https://github.com/moxystudio/postcss-preset-moxy/blob/master/index.js
require('postcss-preset-env')({
browsers: this.browsers,
// https://cssdb.org/
stage: 4,
// Disable `preserve` so that the resulting CSS is consistent among all
// browsers, diminishing the probability of discovering bugs only when
// testing in older browsers.
preserve: false,
// Explicitly enable features that we want, despite being proposals yet.
features: {
'custom-properties': true,
'custom-media-queries': true,
'nesting-rules': true,
'pseudo-class-any-link': true
},
autoprefixer: {
// We don't manually apply prefixes unless they are really necessary,
// e.g.when dealing with quirks, therefore we disable removing them.
remove: false
}
})
];
for (const [stage, plugins] of Object.entries({ before, after })) {
this.addPostcssPlugin(baseConfig, stage, ...plugins);
}
return {
postcssOptions: {
// https://github.com/postcss/postcss-scss
// This allows you to use inline comments, like this one here.
parser: require('postcss-scss')
}
};
}
};