Skip to content

Add an option 'preserveUndefinedVariables' to keeps undefined variables as is in final output #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vithar
Copy link

@vithar vithar commented Sep 2, 2023

Currently postcss-css-variables generates undefined in case it process value with undefined variable.

In some cases this is undesirable behavior and undefined variables should be leaved as is without modification.

This PR adds an new option preserveUndefinedVariables in order to achieve this.

@@ -375,6 +375,12 @@ Keeps your at-rules like media queries in the order to defined them.

Ideally, this would be defaulted to `true` and it will be in the next major version. All of the tests expecations need to be updated and probably just drop support for `preserveAtRulesOrder: false`

### `preserveUndefinedVariables` (default: `false`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vithar Can you give an example of why undefined isn't desired and is conflicting?

Does the existing preserve: true option cover your use case? The undefined value will just fallback to the same preserved value your trying to keep around with this new option.

Copy link

@YoungL1107 YoungL1107 Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
If variable is undefined, the build result is width: undefined;.
And, preserve: true will make css file larger
maybe that's why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants