Comments (8)
Changing it to:
"postcss-advanced-variables": {
importPaths: ['./src/assets/stylesheets/variables.json']
},
doesn't help.
from postcss-advanced-variables.
@pjg, could you give a sample of what your variables.json
file looks like? Otherwise, I may have a lot of trouble debugging this.
I am already testing for this kind of variables support here: https://github.com/jonathantneal/postcss-advanced-variables/blob/master/.tape.js#L6-L13 which defines $default
as custom-fn-value
.
That test then uses this file: https://github.com/jonathantneal/postcss-advanced-variables/blob/master/test/default.css#L4
Which produces this correct result: https://github.com/jonathantneal/postcss-advanced-variables/blob/master/test/default.var-func.expect.css#L2
from postcss-advanced-variables.
My variables.json
file looks like this:
{
"primary-border-radius": "3px",
"blue": "#2ABCDC",
"green": "#53D6AE",
"red": "#E8562A",
...
}
from postcss-advanced-variables.
@pjg, does it have a gray-bg
key? As in, "gray-bg": "YOUR_HEX_VALUE"
? The error says that variable could not be resolved:
Could not resolve the variable "$gray-bg" within "$gray-bg"
from postcss-advanced-variables.
Yes, it has it:
"gray-bg": "#F2F7FA",
from postcss-advanced-variables.
Here’s what I’ve done. I setup a test like this:
postcssVariables({
variables: require('./variables.json')
})
Where variables.json
is:
{
"primary-border-radius": "3px",
"blue": "#2ABCDC",
"green": "#53D6AE",
"red": "#E8562A",
"gray-bg": "#F2F7FA"
}
And then I’ve tested it against this css file:
.test {
color: $gray-bg;
}
And the result is successfully:
.test {
color: #F2F7FA;
}
Because this test is passing, I’m not sure where your issue is coming from. Have you tried to log the require statement to see if it is taking in the right variables?
console.log(require('./src/assets/stylesheets/variables.json'))
The next step would be to get a reduced snippet of your CSS that will cause the error.
from postcss-advanced-variables.
I guess the issue is with running it through webpack in Vue. I'll experiment with different importing options.
from postcss-advanced-variables.
Figured it out.
Turns out, now advanced-variables is more restrictive towards invalid variables being used in CSS files. I had a couple of incorrect references and an @import url("http://...")
statement which didn't work after upgrading to 2.2. I've corrected all of them and things work again. Closing.
Thanks for your support!
from postcss-advanced-variables.
Related Issues (20)
- Publish latest version to npm HOT 1
- Dependency on postcss v7.0.6 exposes security vulnerability (PostCSS < 8.4.31) HOT 1
- Upgrading from v3.0.1 to v4.0.0 triggers warnings in Nuxt HOT 1
- Upgrading to 4.0.0 stops resolving variables HOT 2
- The vite built assetUrl was incorrectly identified as a variable HOT 3
- Handling multi-levels variables? HOT 3
- Can't resolve #{} in webpack postcss plugin HOT 8
- Publish release HOT 3
- TypeError: Cannot read property 'toLowerCase' of undefined HOT 1
- Move postcss to peerDependencies
- Update to use PostCSS v8 HOT 1
- @each don't work properly. HOT 1
- Global declarations HOT 2
- Could not resolve variable $c within #{$c}__label{ ... } HOT 1
- Suggestion for a new feature: Read-Only Variables to Overide other Variables HOT 2
- Could not resolve the variable "$pad" within "calc(100% - $pad * 2)" HOT 1
- Publish to npm HOT 6
- Loading global mixins and variables from file HOT 1
- Variable property name
- Not evaluating number when passing variables
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postcss-advanced-variables.