index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _postcss = require("postcss");
  7. var _transform = _interopRequireDefault(require("./lib/transform"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. var _default = (0, _postcss.plugin)('postcss-calc', function (opts) {
  10. var options = Object.assign({
  11. precision: 5,
  12. preserve: false,
  13. warnWhenCannotResolve: false,
  14. mediaQueries: false,
  15. selectors: false
  16. }, opts);
  17. return function (css, result) {
  18. css.walk(function (node) {
  19. var type = node.type;
  20. if (type === 'decl') {
  21. (0, _transform.default)(node, "value", options, result);
  22. }
  23. if (type === 'atrule' && options.mediaQueries) {
  24. (0, _transform.default)(node, "params", options, result);
  25. }
  26. if (type === 'rule' && options.selectors) {
  27. (0, _transform.default)(node, "selector", options, result);
  28. }
  29. });
  30. };
  31. });
  32. exports.default = _default;
  33. module.exports = exports.default;