Skip to content

Commit 0fb0942

Browse files
committed
Shorter way to pass in "browsers" option to plugins
Note: using string splitting instead of plain array because ¯\_(babel)_/¯
1 parent 853d347 commit 0fb0942

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

src/index.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,25 @@ const plugin = postcss.plugin("postcss-cssnext", (options) => {
1414

1515
const features = options.features
1616

17-
// propagate browsers option to autoprefixer
18-
if (features.autoprefixer !== false) {
19-
features.autoprefixer = {
20-
browsers: (
21-
features.autoprefixer && features.autoprefixer.browsers
22-
? features.autoprefixer.browsers
23-
: options.browsers
24-
),
25-
...(features.autoprefixer || {}),
26-
}
17+
// propagate browsers option to plugins that supports it
18+
"autoprefixer pixrem".split(/\s/).forEach(name => {
19+
const feature = features[name]
2720

28-
// autoprefixer doesn't like an "undefined" value. Related to coffee ?
29-
if (features.autoprefixer.browsers === undefined) {
30-
delete features.autoprefixer.browsers
21+
if (feature !== false) {
22+
features[name] = {
23+
browsers: (
24+
feature && feature.browsers
25+
? feature.browsers
26+
: options.browsers
27+
),
28+
...(feature || {}),
29+
}
3130
}
32-
}
31+
})
3332

34-
// propagate browsers option to pixrem
35-
if (features.pixrem !== false) {
36-
features.pixrem = {
37-
browsers: (
38-
features.pixrem && features.pixrem.browsers
39-
? features.pixrem.browsers
40-
: options.browsers
41-
),
42-
...(features.pixrem || {}),
43-
}
33+
// autoprefixer doesn't like an "undefined" value. Related to coffee ?
34+
if (features.autoprefixer && features.autoprefixer.browsers === undefined) {
35+
delete features.autoprefixer.browsers
4436
}
4537

4638
const processor = postcss()

0 commit comments

Comments
 (0)