【发布时间】:2020-10-12 22:54:28
【问题描述】:
您好 postcss 专家!
我正在将旧插件更新为 postCSS 8 API,但遇到了一些问题。
这个简单的 postCSS 插件陷入了无限循环:
module.exports = (options = {}) => {
return {
postcssPlugin: 'postcss-failing-plugin',
Declaration(decl) {
if (decl.prop.startsWith('--')) {
decl.prop = decl.prop.replace(/^--/, `--prefix-`);
}
},
};
};
module.exports.postcss = true;
文档提到了这种行为:
插件将重新访问您更改或添加的所有节点。如果您要更改任何子级,插件也会重新访问父级。只有
Once和OnceExit不会被再次调用。 writing a plugin
但没有什么可以避免的。
如何编辑Declaration中的值而不造成无限循环?
【问题讨论】:
标签: postcss