Giter Club home page Giter Club logo

Comments (8)

pjg avatar pjg commented on June 26, 2024

Changing it to:

    "postcss-advanced-variables": {
      importPaths: ['./src/assets/stylesheets/variables.json']
    },

doesn't help.

from postcss-advanced-variables.

jonathantneal avatar jonathantneal commented on June 26, 2024

@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.

pjg avatar pjg commented on June 26, 2024

My variables.json file looks like this:

{
  "primary-border-radius": "3px",

  "blue": "#2ABCDC",
  "green": "#53D6AE",
  "red": "#E8562A",
  ...
}

from postcss-advanced-variables.

jonathantneal avatar jonathantneal commented on June 26, 2024

@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.

pjg avatar pjg commented on June 26, 2024

Yes, it has it:

"gray-bg": "#F2F7FA",

from postcss-advanced-variables.

jonathantneal avatar jonathantneal commented on June 26, 2024

Here’s what I’ve done. I setup a test like this:

https://github.com/jonathantneal/postcss-tests/blob/master/postcss-advanced-variables-test-00/test.js#L15-L17

postcssVariables({
  variables: require('./variables.json')
})

Where variables.json is:

https://github.com/jonathantneal/postcss-tests/blob/master/postcss-advanced-variables-test-00/variables.json

{
  "primary-border-radius": "3px",
  "blue": "#2ABCDC",
  "green": "#53D6AE",
  "red": "#E8562A",
  "gray-bg": "#F2F7FA"
}

And then I’ve tested it against this css file:

https://github.com/jonathantneal/postcss-tests/blob/master/postcss-advanced-variables-test-00/test.css#L2

.test {
  color: $gray-bg;
}

And the result is successfully:

https://github.com/jonathantneal/postcss-tests/blob/master/postcss-advanced-variables-test-00/test.expect.css#L2

.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.

pjg avatar pjg commented on June 26, 2024

I guess the issue is with running it through webpack in Vue. I'll experiment with different importing options.

from postcss-advanced-variables.

pjg avatar pjg commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.