Closed 2beers closed 5 years ago
@2beers JS-defined variables just get put in a :root
at the top
You can add the isImportant
option the variable and I think it should take priority, https://github.com/MadLittleMods/postcss-css-variables#variables-default-
cssvariables({
variables: {
"--first-color": {
value: "green",
isImportant: true
}
}
})
Thanks @MadLittleMods . I've tried using isImportant but it returns an error. I tried with both postcss 7.0.5 and 6.0.23 and is the same error. I'm using node v8.11.1
(node:8256) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'parent' of undefined
at findNodeAncestorWithSelector (D:\work\htdocs\project\node_modules\postcss-css-variables\lib\find-node-ancestor-with-selector.js:11:20)
at D:\work\htdocs\project\node_modules\postcss-css-variables\lib\resolve-value.js:86:33
at String.replace (<anonymous>)
at resolveValue (D:\work\htdocs\project\node_modules\postcss-css-variables\lib\resolve-value.js:44:34)
at resolveDecl (D:\work\htdocs\project\node_modules\postcss-css-variables\lib\resolve-decl.js:90:44)
at D:\work\htdocs\project\node_modules\postcss-css-variables\index.js:251:7
at Array.forEach (<anonymous>)
at D:\work\htdocs\project\node_modules\postcss-css-variables\index.js:248:33
at Array.forEach (<anonymous>)
at D:\work\htdocs\project\node_modules\postcss-css-variables\index.js:247:18
@2beers Thanks for the heads-up 👍. Working on a fix now which will probably ship today in a bit, https://github.com/MadLittleMods/postcss-css-variables/pull/87
@2beers
postcss-css-variables@0.11.0
published to npm 🚀, https://www.npmjs.com/package/postcss-css-variables
@MadLittleMods Thanks Eric for your help. Just tested and works great now. Great job
Is there an option that will enable priority for js defined variables over css ones? For example in this css
will output
#box{background-color:red}
and I expected to change the color to green as provided from js optionsThanks