Skip to content

Color Mod doesn't work with Custom Properties #30

Closed
@james-prado

Description

@james-prado

I'm using postcss-preset-env and color-mod() doesn't work with custom css properties

I understand resolving custom properties is difficult without importing the :root {...} styles, but even after importing and resolving custom variables I'm still getting errors.

index.css:

body {
  background-color: color-mod(var(--color-primary) h(64));
}

foo.css:

  :root {
    --color-primary: "#0366d6";
  }

webpack.config:

{
    loader: 'postcss-loader',
    options: {
        plugins: () => [
            postcssPresetEnv({
                stage: 3,
                features: {
                    'color-mod-function': {
                        unresolved: 'warn',
                        importFrom: 'src/assets/foo.css',
                    }
                }
            })
        ]
    }
},

Expected behaviour

input.css

background-color: color-mod(var(--color-primary) hue(64));

output.css

background-color: #cad803;

Actual behaviour

input.css

background-color: color-mod(var(--color-primary) hue(64));

output.css

background-color: color-mod(#0366d6 hue(64));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions