[fix]: Does not parse nested variables
maxmilton opened this issue · comments
I had a look through the existing Github issues but I couldn't find this mention (which is surprising as I would think it's common).
When using nested CSS variables this plugin only replaces the first variable.
Example
:root {
--color: blue;
--nested-variable: var(--color);
}
@whateverAtRule var(--nested-variable);
Current result:
@whateverAtRule var(--color);
Expected:
@whateverAtRule blue;
Workaround
In case anyone is also having this issue, a quick workaround for now is to use the plugin twice, so it resolves the at rule variable twice.
.postcssrc.js
:
module.exports = {
plugins: [
require("postcss-at-rules-variables"),
require("postcss-at-rules-variables")
]
};
@maxmilton good catch, I will try to quickly fix this. Also PR welcome.
@maxmilton done.
Nice 😄
However, I just tested it and I now get this error:
ERROR Failed to compile with 5 errors 15:59:33
error in ./src/views/ViewHomepage.vue
Module build failed: TypeError: Cannot read property 'includes' of undefined
at hasVar (/home/max/Development/wearegenkicom/node_modules/postcss-at-rules-variables/lib/index.js:1:478)
at resolveValue (/home/max/Development/wearegenkicom/node_modules/postcss-at-rules-variables/lib/index.js:1:536)
at /home/max/Development/wearegenkicom/node_modules/postcss-at-rules-variables/lib/index.js:1:966
at Array.reduce (<anonymous>)
at circularReference (/home/max/Development/wearegenkicom/node_modules/postcss-at-rules-variables/lib/index.js:1:905)
at /home/max/Development/wearegenkicom/node_modules/postcss-at-rules-variables/lib/index.js:1:1387
at LazyResult.run (/home/max/Development/wearegenkicom/node_modules/postcss/lib/lazy-result.js:277:20)
at LazyResult.asyncTick (/home/max/Development/wearegenkicom/node_modules/postcss/lib/lazy-result.js:192:32)
at /home/max/Development/wearegenkicom/node_modules/postcss/lib/lazy-result.js:197:27
at <anonymous>
@ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-0818d96d","scoped":false,"hasInlineConfig":false}!./node_modules/postcss-loader/lib?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/views/ViewHomepage.vue 4:14-382 13:3-17:5 14:22-390
@ ./src/views/ViewHomepage.vue
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?https://localhost:4435 webpack/hot/dev-server ./src/main.js
...
@maxmilton please give me more information about this issue, if you can lay out your example on the github will be very good, or show me your css and node version. Thanks!
I created a new issue according to your data