是否有用于求和变量的 PostCSS 插件?

Is there any PostCSS plugins for sum variables?

我现在只使用 precss 插件,但我想像这样计算 PostCSS 中的变量

$sidebar-width: 50px;
$container-padding-left: 20px;

#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: $sidebar-width;
  z-index: 100;
}
#container {
  margin-left: -$sidebar-width;
  padding-left: $sidebar-width + $container-padding-left;
}

postCSS 中有计算 + 的插件吗?

我也试过calc($sidebar-width + $container-padding-left);但是没用。

我查找了https://github.com/postcss/postcss/blob/master/docs/plugins.md 但是我找不到我想要的。

我找到了 postcss-calc https://github.com/postcss/postcss-calc

这就是我想要的。 precss 成功后插入计算模块。

好像你把变量插件放在了 postcss-calc 之后。只要顺序正确就使用PreCSS插件包。

padding-left: $sidebar-width + $container-padding-left;

postcss-automath 做得更好,没有 calc()