1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
8 |
|
9 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
10 |
|
11 | var _postcss = require("postcss");
|
12 |
|
13 | var _postcss2 = _interopRequireDefault(_postcss);
|
14 |
|
15 | var _caniuseApi = require("caniuse-api");
|
16 |
|
17 | var _features = require("./features");
|
18 |
|
19 | var _features2 = _interopRequireDefault(_features);
|
20 |
|
21 | var _featuresActivationMap = require("./features-activation-map");
|
22 |
|
23 | var _featuresActivationMap2 = _interopRequireDefault(_featuresActivationMap);
|
24 |
|
25 | var plugin = _postcss2["default"].plugin("postcss-cssnext", function (options) {
|
26 | options = _extends({
|
27 | features: {}
|
28 | }, options);
|
29 |
|
30 | var features = options.features;
|
31 |
|
32 |
|
33 | if (features.autoprefixer !== false) {
|
34 | features.autoprefixer = _extends({
|
35 | browsers: features.autoprefixer && features.autoprefixer.browsers ? features.autoprefixer.browsers : options.browsers
|
36 | }, features.autoprefixer || {});
|
37 |
|
38 |
|
39 | if (features.autoprefixer.browsers === undefined) {
|
40 | delete features.autoprefixer.browsers;
|
41 | }
|
42 | }
|
43 |
|
44 | var processor = (0, _postcss2["default"])();
|
45 |
|
46 |
|
47 | Object.keys(_features2["default"]).forEach(function (key) {
|
48 |
|
49 |
|
50 | if (
|
51 |
|
52 | features[key] !== false && (
|
53 |
|
54 | features[key] === true ||
|
55 |
|
56 |
|
57 | _featuresActivationMap2["default"][key] === undefined ||
|
58 |
|
59 |
|
60 | _featuresActivationMap2["default"][key] && _featuresActivationMap2["default"][key][0] && !(0, _caniuseApi.isSupported)(_featuresActivationMap2["default"][key][0], options.browsers))) {
|
61 | var _plugin = _features2["default"][key](typeof features[key] === "object" ? _extends({}, features[key]) : undefined);
|
62 | processor.use(_plugin);
|
63 | }
|
64 | });
|
65 |
|
66 | return processor;
|
67 | });
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | plugin.features = _features2["default"];
|
78 |
|
79 | exports["default"] = plugin;
|
80 | module.exports = exports["default"];
|
81 |
|
82 |
|
\ | No newline at end of file |