MadLittleMods / postcss-css-variables

PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation
https://madlittlemods.github.io/postcss-css-variables/playground/
Other
540 stars 62 forks source link

Fails when you pass the variables as an option and use a variable that doesn't exists. #72

Closed igor-ribeiro closed 6 years ago

igor-ribeiro commented 6 years ago

webpack config:

{
  loader: 'postcss-loader',
  options: {
    parser: 'postcss-scss',
    plugins: [
      require('postcss-cssnext')({
        features: {
          customProperties: false,
        },
      }),
      require('postcss-css-variables')({
        variables: {
          '--font': 'Arial',
        },
      }),
    ],
  },

CSS file:

body {
  color: var(--color);
}

Error:

Module build failed: TypeError: resultantValue.replace is not a function

Even with the preserve options it happens.

Is it a bug or it's the expected behavior?

igor-ribeiro commented 6 years ago

If I don't provide the variables option it outputs color: undefined.

igor-ribeiro commented 6 years ago

Never mind, my fault... One of the values was a number. It works as expected.